Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
lexicalunit committed Aug 16, 2024
1 parent b0a0019 commit 7229ac8
Show file tree
Hide file tree
Showing 53 changed files with 250 additions and 217 deletions.
180 changes: 90 additions & 90 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import nest_asyncio
from asgiref.sync import async_to_sync
from IPython import embed

from spellbot.database import db_session_manager, initialize_connection


Expand Down
3 changes: 2 additions & 1 deletion src/spellbot/migrations/env.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from alembic import context
from spellbot.models import Base, import_models
from sqlalchemy import engine_from_config, pool

from spellbot.models import Base, import_models

import_models()
config = context.config
target_metadata = Base.metadata # type: ignore
Expand Down
5 changes: 3 additions & 2 deletions tests/actions/test_lfg_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

import pytest
import pytest_asyncio

from spellbot.actions import LookingForGameAction
from spellbot.enums import GameFormat, GameService

from tests.mocks import mock_discord_object

if TYPE_CHECKING:
import discord
from pytest_mock import MockerFixture

from spellbot import SpellBot
from spellbot.models import User

Expand All @@ -23,7 +24,7 @@ async def action(bot: SpellBot, interaction: discord.Interaction) -> LookingForG
return action


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestLookingForGameAction:
async def test_get_service(self, action: LookingForGameAction) -> None:
assert await action.get_service(GameService.X_MAGE.value) == GameService.X_MAGE.value
Expand Down
8 changes: 4 additions & 4 deletions tests/actions/test_tasks_aciton.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
import pytest
import pytest_asyncio
import pytz

from spellbot.actions import TasksAction
from spellbot.client import build_bot
from spellbot.database import DatabaseSession
from spellbot.services import ChannelsService, GamesService, GuildsService, ServicesRegistry

from tests.mocks import mock_discord_object

if TYPE_CHECKING:
from collections.abc import Callable

from pytest_mock import MockerFixture

from spellbot import SpellBot
from spellbot.models import Channel, Game, Guild

from tests.fixtures import Factories


Expand Down Expand Up @@ -130,7 +130,7 @@ async def bot(mocker: MockerFixture, discord_guild: discord.Guild) -> SpellBot:
return build_bot(mock_games=True, create_connection=False)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestTaskExpireInactiveChannels:
async def test_when_nothing_to_expire(
self,
Expand Down Expand Up @@ -286,7 +286,7 @@ async def test_when_inactive_game_with_players_exists(
)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestTaskCleanupOldVoiceChannels:
async def test_when_nothing_exists(
self,
Expand Down
4 changes: 2 additions & 2 deletions tests/cogs/test_about_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
from typing import TYPE_CHECKING

import pytest

from spellbot import __version__
from spellbot.cogs import AboutCog

from tests.mixins import InteractionMixin

if TYPE_CHECKING:
from freezegun.api import FrozenDateTimeFactory


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAbout(InteractionMixin):
async def test_about(self, freezer: FrozenDateTimeFactory) -> None:
freezer.move_to("2021-03-01")
Expand Down
26 changes: 13 additions & 13 deletions tests/cogs/test_admin_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import discord
import pytest
import pytest_asyncio

from spellbot.actions import admin_action
from spellbot.cogs import AdminCog
from spellbot.database import DatabaseSession
from spellbot.enums import GameFormat, GameService
from spellbot.errors import AdminOnlyError
from spellbot.models import Channel, Game, Guild, GuildAward
from spellbot.views import SetupView

from tests.mixins import InteractionMixin
from tests.mocks import mock_discord_user, mock_operations

Expand All @@ -22,8 +22,8 @@

from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture
from spellbot.client import SpellBot

from spellbot.client import SpellBot
from tests.fixtures import Factories


Expand All @@ -42,7 +42,7 @@ async def use_consistent_date(freezer: FrozenDateTimeFactory) -> None:
freezer.move_to("2021-03-01")


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminSetup(InteractionMixin):
async def test_setup(self, cog: AdminCog) -> None:
await self.run(cog.setup)
Expand Down Expand Up @@ -100,7 +100,7 @@ async def test_setup(self, cog: AdminCog) -> None:
}


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestSetupView(InteractionMixin):
@pytest_asyncio.fixture
async def admin(self, factories: Factories, mocker: MockerFixture) -> discord.User:
Expand All @@ -121,7 +121,7 @@ async def test_setup_when_not_admin(self, view: SetupView, non_admin: discord.Us
await view.interaction_check(self.interaction)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminMotd(InteractionMixin):
async def test_set_motd(self, cog: AdminCog) -> None:
await self.run(cog.motd, message="this is a test")
Expand All @@ -138,7 +138,7 @@ async def test_set_motd(self, cog: AdminCog) -> None:
assert guild.motd == ""


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminSetupView(InteractionMixin):
async def test_refresh_setup(self, view: SetupView) -> None:
await view.refresh_setup.callback(self.interaction)
Expand Down Expand Up @@ -210,7 +210,7 @@ async def test_toggle_voice_create(self, view: SetupView) -> None:
assert guild.voice_create != Guild.voice_create.default.arg # type: ignore


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminInfo(InteractionMixin):
async def test_happy_path(
self,
Expand Down Expand Up @@ -250,7 +250,7 @@ async def test_non_existant_game_id(self, cog: AdminCog) -> None:
)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminChannels(InteractionMixin):
async def test_default_seats(self, cog: AdminCog) -> None:
seats = Channel.default_seats.default.arg - 1 # type: ignore
Expand Down Expand Up @@ -492,7 +492,7 @@ async def test_channels_with_pagination(self, cog: AdminCog, page: int) -> None:
)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminAwards(InteractionMixin):
async def test_awards(self, cog: AdminCog) -> None:
award1 = self.factories.guild_award.create(
Expand Down Expand Up @@ -629,7 +629,7 @@ async def test_award_add_zero_count(self, cog: AdminCog) -> None:
assert DatabaseSession.query(GuildAward).count() == 0


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminDeleteExpired(InteractionMixin):
@pytest.mark.parametrize("setting", [True, False])
async def test_set_delete_expired(self, cog: AdminCog, setting: bool) -> None:
Expand All @@ -642,7 +642,7 @@ async def test_set_delete_expired(self, cog: AdminCog, setting: bool) -> None:
assert channel.delete_expired is setting


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminShowPoints(InteractionMixin):
@pytest.mark.parametrize("setting", [True, False])
async def test_set_show_points(self, cog: AdminCog, setting: bool) -> None:
Expand All @@ -655,7 +655,7 @@ async def test_set_show_points(self, cog: AdminCog, setting: bool) -> None:
assert channel.show_points is setting


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminRequireConfirmation(InteractionMixin):
@pytest.mark.parametrize("setting", [True, False])
async def test_set_require_confirmation(self, cog: AdminCog, setting: bool) -> None:
Expand All @@ -668,7 +668,7 @@ async def test_set_require_confirmation(self, cog: AdminCog, setting: bool) -> N
assert channel.require_confirmation is setting


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogAdminVoiceInvite(InteractionMixin):
@pytest.mark.parametrize("setting", [True, False])
async def test_set_voice_invite(self, cog: AdminCog, setting: bool) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/cogs/test_block_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import pytest
import pytest_asyncio

from spellbot.cogs import BlockCog
from spellbot.database import DatabaseSession
from spellbot.models import Block, User

from tests.mixins import InteractionMixin

if TYPE_CHECKING:
Expand All @@ -20,7 +20,7 @@ async def cog(bot: SpellBot) -> BlockCog:
return BlockCog(bot)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogBlock(InteractionMixin):
async def test_block_and_unblock(self, cog: BlockCog) -> None:
target = MagicMock()
Expand Down
9 changes: 5 additions & 4 deletions tests/cogs/test_events_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@
from typing import TYPE_CHECKING, cast

import pytest
from sqlalchemy.sql.expression import and_

from spellbot.actions import lfg_action
from spellbot.cogs import EventsCog
from spellbot.database import DatabaseSession
from spellbot.enums import GameFormat
from spellbot.models import Game, GameStatus, Play, User
from sqlalchemy.sql.expression import and_

from tests.mixins import InteractionMixin
from tests.mocks import mock_discord_object, mock_operations

if TYPE_CHECKING:
from collections.abc import Callable

import discord

from spellbot.client import SpellBot


@pytest.fixture()
@pytest.fixture
def cog(bot: SpellBot) -> EventsCog:
return EventsCog(bot)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogEvents(InteractionMixin):
async def test_game(
self,
Expand Down
5 changes: 3 additions & 2 deletions tests/cogs/test_leave_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@

import pytest
import pytest_asyncio

from spellbot.actions import leave_action
from spellbot.cogs import LeaveGameCog
from spellbot.database import DatabaseSession
from spellbot.views.lfg_view import PendingGameView

from tests.mixins import InteractionMixin
from tests.mocks import mock_operations

if TYPE_CHECKING:
import discord
from freezegun.api import FrozenDateTimeFactory

from spellbot.client import SpellBot
from spellbot.models import User

Expand All @@ -30,7 +31,7 @@ async def use_consistent_date(freezer: FrozenDateTimeFactory) -> None:
freezer.move_to("2021-03-01")


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogLeaveGame(InteractionMixin):
async def test_leave(self, cog: LeaveGameCog, message: discord.Message, player: User) -> None:
with mock_operations(leave_action):
Expand Down
11 changes: 6 additions & 5 deletions tests/cogs/test_lfg_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,36 @@
import pytest
import pytest_asyncio
import pytz

from spellbot.actions import lfg_action
from spellbot.cogs import LookingForGameCog
from spellbot.database import DatabaseSession
from spellbot.enums import GameFormat, GameService
from spellbot.models import Channel, Game, GameStatus, Queue, User
from spellbot.views import PendingGameView

from tests.mixins import InteractionMixin
from tests.mocks import mock_discord_object, mock_operations

if TYPE_CHECKING:
from collections.abc import Callable

from freezegun.api import FrozenDateTimeFactory
from spellbot.client import SpellBot
from syrupy.assertion import SnapshotAssertion

from spellbot.client import SpellBot


@pytest_asyncio.fixture(autouse=True)
async def use_consistent_date(freezer: FrozenDateTimeFactory) -> None:
freezer.move_to("2021-03-01")


@pytest.fixture()
@pytest.fixture
def cog(bot: SpellBot) -> LookingForGameCog:
return LookingForGameCog(bot)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogLookingForGame(InteractionMixin):
async def test_lfg(self, cog: LookingForGameCog, channel: Channel) -> None:
await self.run(cog.lfg)
Expand Down Expand Up @@ -223,7 +224,7 @@ async def test_lfg_multiple_times(self, cog: LookingForGameCog, channel: Channel
assert DatabaseSession.query(Game).count() == 1


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogLookingForGameJoinButton(InteractionMixin):
async def test_join(self, game: Game, user: User, message: discord.Message) -> None:
with (
Expand Down
4 changes: 2 additions & 2 deletions tests/cogs/test_lfg_cog_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import discord
import pytest

from spellbot.actions import lfg_action
from spellbot.cogs import LookingForGameCog
from spellbot.database import DatabaseSession
from spellbot.models import Game

from tests.mocks import build_author, build_channel, build_guild, build_interaction

if TYPE_CHECKING:
Expand All @@ -28,7 +28,7 @@ async def run_lfg(cog: LookingForGameCog, interaction: discord.Interaction) -> N
return await callback(interaction=interaction)


@pytest.mark.asyncio()
@pytest.mark.asyncio
class TestCogLookingForGameConcurrency:
async def test_concurrent_lfg_requests_different_channels(self, bot: SpellBot) -> None:
cog = LookingForGameCog(bot)
Expand Down
Loading

0 comments on commit 7229ac8

Please sign in to comment.