mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 23:55:46 +02:00
WORDLE
This commit is contained in:
parent
ea4181eac0
commit
db499f3742
20 changed files with 350 additions and 101 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import datetime
|
||||
|
||||
import pytest
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import users
|
||||
from database.schemas.relational import (
|
||||
|
|
@ -22,7 +23,7 @@ def test_user_id() -> int:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
async def user(postgres, test_user_id) -> User:
|
||||
async def user(postgres: AsyncSession, test_user_id: int) -> User:
|
||||
"""Fixture to create a user"""
|
||||
_user = await users.get_or_add(postgres, test_user_id)
|
||||
await postgres.refresh(_user)
|
||||
|
|
@ -30,7 +31,7 @@ async def user(postgres, test_user_id) -> User:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
async def bank(postgres, user: User) -> Bank:
|
||||
async def bank(postgres: AsyncSession, user: User) -> Bank:
|
||||
"""Fixture to fetch the test user's bank"""
|
||||
_bank = user.bank
|
||||
await postgres.refresh(_bank)
|
||||
|
|
@ -38,7 +39,7 @@ async def bank(postgres, user: User) -> Bank:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
async def ufora_course(postgres) -> UforaCourse:
|
||||
async def ufora_course(postgres: AsyncSession) -> UforaCourse:
|
||||
"""Fixture to create a course"""
|
||||
course = UforaCourse(name="test", code="code", year=1, log_announcements=True)
|
||||
postgres.add(course)
|
||||
|
|
@ -47,7 +48,7 @@ async def ufora_course(postgres) -> UforaCourse:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
async def ufora_course_with_alias(postgres, ufora_course: UforaCourse) -> UforaCourse:
|
||||
async def ufora_course_with_alias(postgres: AsyncSession, ufora_course: UforaCourse) -> UforaCourse:
|
||||
"""Fixture to create a course with an alias"""
|
||||
alias = UforaCourseAlias(course_id=ufora_course.course_id, alias="alias")
|
||||
postgres.add(alias)
|
||||
|
|
@ -57,7 +58,7 @@ async def ufora_course_with_alias(postgres, ufora_course: UforaCourse) -> UforaC
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
async def ufora_announcement(ufora_course: UforaCourse, postgres) -> UforaAnnouncement:
|
||||
async def ufora_announcement(postgres: AsyncSession, ufora_course: UforaCourse) -> UforaAnnouncement:
|
||||
"""Fixture to create an announcement"""
|
||||
announcement = UforaAnnouncement(course_id=ufora_course.course_id, publication_date=datetime.datetime.now())
|
||||
postgres.add(announcement)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import birthdays as crud
|
||||
from database.crud import users
|
||||
from database.schemas.relational import User
|
||||
|
||||
|
||||
async def test_add_birthday_not_present(postgres, user: User):
|
||||
async def test_add_birthday_not_present(postgres: AsyncSession, user: User):
|
||||
"""Test setting a user's birthday when it doesn't exist yet"""
|
||||
assert user.birthday is None
|
||||
|
||||
|
|
@ -18,7 +19,7 @@ async def test_add_birthday_not_present(postgres, user: User):
|
|||
assert user.birthday.birthday == bd_date
|
||||
|
||||
|
||||
async def test_add_birthday_overwrite(postgres, user: User):
|
||||
async def test_add_birthday_overwrite(postgres: AsyncSession, user: User):
|
||||
"""Test that setting a user's birthday when it already exists overwrites it"""
|
||||
bd_date = datetime.today().date()
|
||||
await crud.add_birthday(postgres, user.user_id, bd_date)
|
||||
|
|
@ -31,7 +32,7 @@ async def test_add_birthday_overwrite(postgres, user: User):
|
|||
assert user.birthday.birthday == new_bd_date
|
||||
|
||||
|
||||
async def test_get_birthday_exists(postgres, user: User):
|
||||
async def test_get_birthday_exists(postgres: AsyncSession, user: User):
|
||||
"""Test getting a user's birthday when it exists"""
|
||||
bd_date = datetime.today().date()
|
||||
await crud.add_birthday(postgres, user.user_id, bd_date)
|
||||
|
|
@ -42,14 +43,14 @@ async def test_get_birthday_exists(postgres, user: User):
|
|||
assert bd.birthday == bd_date
|
||||
|
||||
|
||||
async def test_get_birthday_not_exists(postgres, user: User):
|
||||
async def test_get_birthday_not_exists(postgres: AsyncSession, user: User):
|
||||
"""Test getting a user's birthday when it doesn't exist"""
|
||||
bd = await crud.get_birthday_for_user(postgres, user.user_id)
|
||||
assert bd is None
|
||||
|
||||
|
||||
@freeze_time("2022/07/23")
|
||||
async def test_get_birthdays_on_day(postgres, user: User):
|
||||
async def test_get_birthdays_on_day(postgres: AsyncSession, user: User):
|
||||
"""Test getting all birthdays on a given day"""
|
||||
await crud.add_birthday(postgres, user.user_id, datetime.today().replace(year=2001))
|
||||
|
||||
|
|
@ -61,7 +62,7 @@ async def test_get_birthdays_on_day(postgres, user: User):
|
|||
|
||||
|
||||
@freeze_time("2022/07/23")
|
||||
async def test_get_birthdays_none_present(postgres):
|
||||
async def test_get_birthdays_none_present(postgres: AsyncSession):
|
||||
"""Test getting all birthdays when there are none"""
|
||||
birthdays = await crud.get_birthdays_on_day(postgres, datetime.today())
|
||||
assert len(birthdays) == 0
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ import datetime
|
|||
|
||||
import pytest
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import currency as crud
|
||||
from database.exceptions import currency as exceptions
|
||||
from database.schemas.relational import Bank
|
||||
|
||||
|
||||
async def test_add_dinks(postgres, bank: Bank):
|
||||
async def test_add_dinks(postgres: AsyncSession, bank: Bank):
|
||||
"""Test adding dinks to an account"""
|
||||
assert bank.dinks == 0
|
||||
await crud.add_dinks(postgres, bank.user_id, 10)
|
||||
|
|
@ -17,7 +18,7 @@ async def test_add_dinks(postgres, bank: Bank):
|
|||
|
||||
|
||||
@freeze_time("2022/07/23")
|
||||
async def test_claim_nightly_available(postgres, bank: Bank):
|
||||
async def test_claim_nightly_available(postgres: AsyncSession, bank: Bank):
|
||||
"""Test claiming nightlies when it hasn't been done yet"""
|
||||
await crud.claim_nightly(postgres, bank.user_id)
|
||||
await postgres.refresh(bank)
|
||||
|
|
@ -28,7 +29,7 @@ async def test_claim_nightly_available(postgres, bank: Bank):
|
|||
|
||||
|
||||
@freeze_time("2022/07/23")
|
||||
async def test_claim_nightly_unavailable(postgres, bank: Bank):
|
||||
async def test_claim_nightly_unavailable(postgres: AsyncSession, bank: Bank):
|
||||
"""Test claiming nightlies twice in a day"""
|
||||
await crud.claim_nightly(postgres, bank.user_id)
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ async def test_claim_nightly_unavailable(postgres, bank: Bank):
|
|||
assert bank.dinks == crud.NIGHTLY_AMOUNT
|
||||
|
||||
|
||||
async def test_invest(postgres, bank: Bank):
|
||||
async def test_invest(postgres: AsyncSession, bank: Bank):
|
||||
"""Test investing some Dinks"""
|
||||
bank.dinks = 100
|
||||
postgres.add(bank)
|
||||
|
|
@ -52,7 +53,7 @@ async def test_invest(postgres, bank: Bank):
|
|||
assert bank.invested == 20
|
||||
|
||||
|
||||
async def test_invest_all(postgres, bank: Bank):
|
||||
async def test_invest_all(postgres: AsyncSession, bank: Bank):
|
||||
"""Test investing all dinks"""
|
||||
bank.dinks = 100
|
||||
postgres.add(bank)
|
||||
|
|
@ -65,7 +66,7 @@ async def test_invest_all(postgres, bank: Bank):
|
|||
assert bank.invested == 100
|
||||
|
||||
|
||||
async def test_invest_more_than_owned(postgres, bank: Bank):
|
||||
async def test_invest_more_than_owned(postgres: AsyncSession, bank: Bank):
|
||||
"""Test investing more Dinks than you own"""
|
||||
bank.dinks = 100
|
||||
postgres.add(bank)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import pytest
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import custom_commands as crud
|
||||
from database.exceptions.constraints import DuplicateInsertException
|
||||
|
|
@ -7,7 +8,7 @@ from database.exceptions.not_found import NoResultFoundException
|
|||
from database.schemas.relational import CustomCommand
|
||||
|
||||
|
||||
async def test_create_command_non_existing(postgres):
|
||||
async def test_create_command_non_existing(postgres: AsyncSession):
|
||||
"""Test creating a new command when it doesn't exist yet"""
|
||||
await crud.create_command(postgres, "name", "response")
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ async def test_create_command_non_existing(postgres):
|
|||
assert commands[0].name == "name"
|
||||
|
||||
|
||||
async def test_create_command_duplicate_name(postgres):
|
||||
async def test_create_command_duplicate_name(postgres: AsyncSession):
|
||||
"""Test creating a command when the name already exists"""
|
||||
await crud.create_command(postgres, "name", "response")
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ async def test_create_command_duplicate_name(postgres):
|
|||
await crud.create_command(postgres, "name", "other response")
|
||||
|
||||
|
||||
async def test_create_command_name_is_alias(postgres):
|
||||
async def test_create_command_name_is_alias(postgres: AsyncSession):
|
||||
"""Test creating a command when the name is taken by an alias"""
|
||||
await crud.create_command(postgres, "name", "response")
|
||||
await crud.create_alias(postgres, "name", "n")
|
||||
|
|
@ -33,7 +34,7 @@ async def test_create_command_name_is_alias(postgres):
|
|||
await crud.create_command(postgres, "n", "other response")
|
||||
|
||||
|
||||
async def test_create_alias(postgres):
|
||||
async def test_create_alias(postgres: AsyncSession):
|
||||
"""Test creating an alias when the name is still free"""
|
||||
command = await crud.create_command(postgres, "name", "response")
|
||||
await crud.create_alias(postgres, command.name, "n")
|
||||
|
|
@ -43,13 +44,13 @@ async def test_create_alias(postgres):
|
|||
assert command.aliases[0].alias == "n"
|
||||
|
||||
|
||||
async def test_create_alias_non_existing(postgres):
|
||||
async def test_create_alias_non_existing(postgres: AsyncSession):
|
||||
"""Test creating an alias when the command doesn't exist"""
|
||||
with pytest.raises(NoResultFoundException):
|
||||
await crud.create_alias(postgres, "name", "alias")
|
||||
|
||||
|
||||
async def test_create_alias_duplicate(postgres):
|
||||
async def test_create_alias_duplicate(postgres: AsyncSession):
|
||||
"""Test creating an alias when another alias already has this name"""
|
||||
command = await crud.create_command(postgres, "name", "response")
|
||||
await crud.create_alias(postgres, command.name, "n")
|
||||
|
|
@ -58,7 +59,7 @@ async def test_create_alias_duplicate(postgres):
|
|||
await crud.create_alias(postgres, command.name, "n")
|
||||
|
||||
|
||||
async def test_create_alias_is_command(postgres):
|
||||
async def test_create_alias_is_command(postgres: AsyncSession):
|
||||
"""Test creating an alias when the name is taken by a command"""
|
||||
await crud.create_command(postgres, "n", "response")
|
||||
command = await crud.create_command(postgres, "name", "response")
|
||||
|
|
@ -67,7 +68,7 @@ async def test_create_alias_is_command(postgres):
|
|||
await crud.create_alias(postgres, command.name, "n")
|
||||
|
||||
|
||||
async def test_create_alias_match_by_alias(postgres):
|
||||
async def test_create_alias_match_by_alias(postgres: AsyncSession):
|
||||
"""Test creating an alias for a command when matching the name to another alias"""
|
||||
command = await crud.create_command(postgres, "name", "response")
|
||||
await crud.create_alias(postgres, command.name, "a1")
|
||||
|
|
@ -75,21 +76,21 @@ async def test_create_alias_match_by_alias(postgres):
|
|||
assert alias.command == command
|
||||
|
||||
|
||||
async def test_get_command_by_name_exists(postgres):
|
||||
async def test_get_command_by_name_exists(postgres: AsyncSession):
|
||||
"""Test getting a command by name"""
|
||||
await crud.create_command(postgres, "name", "response")
|
||||
command = await crud.get_command(postgres, "name")
|
||||
assert command is not None
|
||||
|
||||
|
||||
async def test_get_command_by_cleaned_name(postgres):
|
||||
async def test_get_command_by_cleaned_name(postgres: AsyncSession):
|
||||
"""Test getting a command by the cleaned version of the name"""
|
||||
command = await crud.create_command(postgres, "CAPITALIZED NAME WITH SPACES", "response")
|
||||
found = await crud.get_command(postgres, "capitalizednamewithspaces")
|
||||
assert command == found
|
||||
|
||||
|
||||
async def test_get_command_by_alias(postgres):
|
||||
async def test_get_command_by_alias(postgres: AsyncSession):
|
||||
"""Test getting a command by an alias"""
|
||||
command = await crud.create_command(postgres, "name", "response")
|
||||
await crud.create_alias(postgres, command.name, "a1")
|
||||
|
|
@ -99,12 +100,12 @@ async def test_get_command_by_alias(postgres):
|
|||
assert command == found
|
||||
|
||||
|
||||
async def test_get_command_non_existing(postgres):
|
||||
async def test_get_command_non_existing(postgres: AsyncSession):
|
||||
"""Test getting a command when it doesn't exist"""
|
||||
assert await crud.get_command(postgres, "name") is None
|
||||
|
||||
|
||||
async def test_edit_command(postgres):
|
||||
async def test_edit_command(postgres: AsyncSession):
|
||||
"""Test editing an existing command"""
|
||||
command = await crud.create_command(postgres, "name", "response")
|
||||
await crud.edit_command(postgres, command.name, "new name", "new response")
|
||||
|
|
@ -112,7 +113,7 @@ async def test_edit_command(postgres):
|
|||
assert command.response == "new response"
|
||||
|
||||
|
||||
async def test_edit_command_non_existing(postgres):
|
||||
async def test_edit_command_non_existing(postgres: AsyncSession):
|
||||
"""Test editing a command that doesn't exist"""
|
||||
with pytest.raises(NoResultFoundException):
|
||||
await crud.edit_command(postgres, "name", "n", "r")
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import dad_jokes as crud
|
||||
from database.schemas.relational import DadJoke
|
||||
|
||||
|
||||
async def test_add_dad_joke(postgres):
|
||||
async def test_add_dad_joke(postgres: AsyncSession):
|
||||
"""Test creating a new joke"""
|
||||
statement = select(DadJoke)
|
||||
result = (await postgres.execute(statement)).scalars().all()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import datetime
|
|||
import pytest
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import tasks as crud
|
||||
from database.enums import TaskType
|
||||
|
|
@ -16,7 +17,7 @@ def task_type() -> TaskType:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
async def task(postgres, task_type: TaskType) -> Task:
|
||||
async def task(postgres: AsyncSession, task_type: TaskType) -> Task:
|
||||
"""Fixture to create a task"""
|
||||
task = Task(task=task_type)
|
||||
postgres.add(task)
|
||||
|
|
@ -24,21 +25,21 @@ async def task(postgres, task_type: TaskType) -> Task:
|
|||
return task
|
||||
|
||||
|
||||
async def test_get_task_by_enum_present(postgres, task: Task, task_type: TaskType):
|
||||
async def test_get_task_by_enum_present(postgres: AsyncSession, task: Task, task_type: TaskType):
|
||||
"""Test getting a task by its enum type when it exists"""
|
||||
result = await crud.get_task_by_enum(postgres, task_type)
|
||||
assert result is not None
|
||||
assert result == task
|
||||
|
||||
|
||||
async def test_get_task_by_enum_not_present(postgres, task_type: TaskType):
|
||||
async def test_get_task_by_enum_not_present(postgres: AsyncSession, task_type: TaskType):
|
||||
"""Test getting a task by its enum type when it doesn't exist"""
|
||||
result = await crud.get_task_by_enum(postgres, task_type)
|
||||
assert result is None
|
||||
|
||||
|
||||
@freeze_time("2022/07/24")
|
||||
async def test_set_execution_time_exists(postgres, task: Task, task_type: TaskType):
|
||||
async def test_set_execution_time_exists(postgres: AsyncSession, task: Task, task_type: TaskType):
|
||||
"""Test setting the execution time of an existing task"""
|
||||
await postgres.refresh(task)
|
||||
assert task.previous_run is None
|
||||
|
|
@ -49,7 +50,7 @@ async def test_set_execution_time_exists(postgres, task: Task, task_type: TaskTy
|
|||
|
||||
|
||||
@freeze_time("2022/07/24")
|
||||
async def test_set_execution_time_doesnt_exist(postgres, task_type: TaskType):
|
||||
async def test_set_execution_time_doesnt_exist(postgres: AsyncSession, task_type: TaskType):
|
||||
"""Test setting the execution time of a non-existing task"""
|
||||
statement = select(Task).where(Task.task == task_type)
|
||||
results = list((await postgres.execute(statement)).scalars().all())
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
import datetime
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import ufora_announcements as crud
|
||||
from database.schemas.relational import UforaAnnouncement, UforaCourse
|
||||
|
||||
|
||||
async def test_get_courses_with_announcements_none(postgres):
|
||||
async def test_get_courses_with_announcements_none(postgres: AsyncSession):
|
||||
"""Test getting all courses with announcements when there are none"""
|
||||
results = await crud.get_courses_with_announcements(postgres)
|
||||
assert len(results) == 0
|
||||
|
||||
|
||||
async def test_get_courses_with_announcements(postgres):
|
||||
async def test_get_courses_with_announcements(postgres: AsyncSession):
|
||||
"""Test getting all courses with announcements"""
|
||||
course_1 = UforaCourse(name="test", code="code", year=1, log_announcements=True)
|
||||
course_2 = UforaCourse(name="test2", code="code2", year=1, log_announcements=False)
|
||||
|
|
@ -22,14 +24,14 @@ async def test_get_courses_with_announcements(postgres):
|
|||
assert results[0] == course_1
|
||||
|
||||
|
||||
async def test_create_new_announcement(ufora_course: UforaCourse, postgres):
|
||||
async def test_create_new_announcement(postgres: AsyncSession, ufora_course: UforaCourse):
|
||||
"""Test creating a new announcement"""
|
||||
await crud.create_new_announcement(postgres, 1, course=ufora_course, publication_date=datetime.datetime.now())
|
||||
await postgres.refresh(ufora_course)
|
||||
assert len(ufora_course.announcements) == 1
|
||||
|
||||
|
||||
async def test_remove_old_announcements(ufora_announcement: UforaAnnouncement, postgres):
|
||||
async def test_remove_old_announcements(postgres: AsyncSession, ufora_announcement: UforaAnnouncement):
|
||||
"""Test removing all stale announcements"""
|
||||
course = ufora_announcement.course
|
||||
ufora_announcement.publication_date -= datetime.timedelta(weeks=2)
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import ufora_courses as crud
|
||||
from database.schemas.relational import UforaCourse
|
||||
|
||||
|
||||
async def test_get_course_by_name_exact(postgres, ufora_course: UforaCourse):
|
||||
async def test_get_course_by_name_exact(postgres: AsyncSession, ufora_course: UforaCourse):
|
||||
"""Test getting a course by its name when the query is an exact match"""
|
||||
match = await crud.get_course_by_name(postgres, "Test")
|
||||
assert match == ufora_course
|
||||
|
||||
|
||||
async def test_get_course_by_name_substring(postgres, ufora_course: UforaCourse):
|
||||
async def test_get_course_by_name_substring(postgres: AsyncSession, ufora_course: UforaCourse):
|
||||
"""Test getting a course by its name when the query is a substring"""
|
||||
match = await crud.get_course_by_name(postgres, "es")
|
||||
assert match == ufora_course
|
||||
|
||||
|
||||
async def test_get_course_by_name_alias(postgres, ufora_course_with_alias: UforaCourse):
|
||||
async def test_get_course_by_name_alias(postgres: AsyncSession, ufora_course_with_alias: UforaCourse):
|
||||
"""Test getting a course by its name when the name doesn't match, but the alias does"""
|
||||
match = await crud.get_course_by_name(postgres, "ali")
|
||||
assert match == ufora_course_with_alias
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import users as crud
|
||||
from database.schemas.relational import User
|
||||
|
||||
|
||||
async def test_get_or_add_non_existing(postgres):
|
||||
async def test_get_or_add_non_existing(postgres: AsyncSession):
|
||||
"""Test get_or_add for a user that doesn't exist"""
|
||||
await crud.get_or_add(postgres, 1)
|
||||
statement = select(User)
|
||||
|
|
@ -15,7 +16,7 @@ async def test_get_or_add_non_existing(postgres):
|
|||
assert res[0].nightly_data is not None
|
||||
|
||||
|
||||
async def test_get_or_add_existing(postgres):
|
||||
async def test_get_or_add_existing(postgres: AsyncSession):
|
||||
"""Test get_or_add for a user that does exist"""
|
||||
user = await crud.get_or_add(postgres, 1)
|
||||
bank = user.bank
|
||||
|
|
|
|||
|
|
@ -19,24 +19,24 @@ async def wordle_game(wordle_collection: MongoCollection, test_user_id: int) ->
|
|||
yield game
|
||||
|
||||
|
||||
async def test_start_new_game(wordle_collection: MongoCollection, test_user_id: int):
|
||||
async def test_start_new_game(mongodb: MongoDatabase, wordle_collection: MongoCollection, test_user_id: int):
|
||||
"""Test starting a new game"""
|
||||
result = await wordle_collection.find_one({"user_id": test_user_id})
|
||||
assert result is None
|
||||
|
||||
await crud.start_new_wordle_game(wordle_collection, test_user_id)
|
||||
await crud.start_new_wordle_game(mongodb, test_user_id)
|
||||
|
||||
result = await wordle_collection.find_one({"user_id": test_user_id})
|
||||
assert result is not None
|
||||
|
||||
|
||||
async def test_get_active_wordle_game_none(wordle_collection: MongoCollection, test_user_id: int):
|
||||
async def test_get_active_wordle_game_none(mongodb: MongoDatabase, test_user_id: int):
|
||||
"""Test getting an active game when there is none"""
|
||||
result = await crud.get_active_wordle_game(wordle_collection, test_user_id)
|
||||
result = await crud.get_active_wordle_game(mongodb, test_user_id)
|
||||
assert result is None
|
||||
|
||||
|
||||
async def test_get_active_wordle_game(wordle_collection: MongoCollection, wordle_game: WordleGame):
|
||||
async def test_get_active_wordle_game(mongodb: MongoDatabase, wordle_game: WordleGame):
|
||||
"""Test getting an active game when there is none"""
|
||||
result = await crud.get_active_wordle_game(wordle_collection, wordle_game.user_id)
|
||||
assert result == wordle_game.dict(by_alias=True)
|
||||
result = await crud.get_active_wordle_game(mongodb, wordle_game.user_id)
|
||||
assert result.dict(by_alias=True) == wordle_game.dict(by_alias=True)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.schemas.relational import UforaCourse
|
||||
from database.utils.caches import UforaCourseCache
|
||||
|
||||
|
||||
async def test_ufora_course_cache_refresh_empty(postgres, ufora_course_with_alias: UforaCourse):
|
||||
async def test_ufora_course_cache_refresh_empty(postgres: AsyncSession, ufora_course_with_alias: UforaCourse):
|
||||
"""Test loading the data for the Ufora Course cache when it's empty"""
|
||||
cache = UforaCourseCache()
|
||||
await cache.refresh(postgres)
|
||||
|
|
@ -12,7 +14,7 @@ async def test_ufora_course_cache_refresh_empty(postgres, ufora_course_with_alia
|
|||
assert cache.aliases == {"alias": "test"}
|
||||
|
||||
|
||||
async def test_ufora_course_cache_refresh_not_empty(postgres, ufora_course_with_alias: UforaCourse):
|
||||
async def test_ufora_course_cache_refresh_not_empty(postgres: AsyncSession, ufora_course_with_alias: UforaCourse):
|
||||
"""Test loading the data for the Ufora Course cache when it's not empty anymore"""
|
||||
cache = UforaCourseCache()
|
||||
cache.data = ["Something"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue