-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76a903c
commit 6ba2bfe
Showing
12 changed files
with
149 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
codecov: | ||
branch: master | ||
|
||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: auto | ||
threshold: 10% | ||
|
||
comment: | ||
layout: "diff, flags, files" | ||
behavior: default | ||
require_changes: false # if true: only post the comment if coverage changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest==8.1.1 | ||
pytest-asyncio==0.23.6 | ||
pytest-cov==5.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# lib imports | ||
import dotenv | ||
|
||
dotenv.load_dotenv(override=False) # environment secrets take priority over .env file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# standard imports | ||
import asyncio | ||
|
||
# lib imports | ||
import pytest | ||
import pytest_asyncio | ||
|
||
# local imports | ||
from src import discord_bot | ||
from src import discord_avatar | ||
from src import discord_constants | ||
|
||
|
||
@pytest_asyncio.fixture | ||
async def bot(): | ||
# event_loop fixture is deprecated | ||
_loop = asyncio.get_event_loop() | ||
|
||
bot = discord_bot.get_bot(loop=_loop) | ||
future = asyncio.run_coroutine_threadsafe(bot.start(token=discord_bot.bot_token), _loop) | ||
await bot.wait_until_ready() # Wait until the bot is ready | ||
yield bot | ||
discord_bot.stop(future=future) | ||
|
||
# wait for the bot to finish | ||
counter = 0 | ||
while not future.done() and counter < 30: | ||
await asyncio.sleep(1) | ||
counter += 1 | ||
future.cancel() # Cancel the bot when the tests are done | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_bot_on_ready(bot): | ||
assert bot is not None | ||
assert bot.guilds | ||
assert bot.guilds[0].name == "ReenigneArcher's test server" | ||
assert bot.user.id == 939171917578002502 | ||
assert bot.user.name == discord_constants.bot_name | ||
assert bot.user.avatar | ||
|
||
# compare the bot avatar to our intended avatar | ||
assert await bot.user.avatar.read() == discord_avatar.avatar_img |