Fix wordle code

This commit is contained in:
stijndcl 2022-08-29 20:49:29 +02:00
parent 8a4baf6bb8
commit 73d44de46e
11 changed files with 58 additions and 48 deletions

View file

@ -25,7 +25,7 @@ def test_user_id() -> int:
@pytest.fixture
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)
_user = await users.get_or_add_user(postgres, test_user_id)
await postgres.refresh(_user)
return _user

View file

@ -54,7 +54,7 @@ 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))
user_2 = await users.get_or_add(postgres, user.user_id + 1)
user_2 = await users.get_or_add_user(postgres, user.user_id + 1)
await crud.add_birthday(postgres, user_2.user_id, datetime.today() + timedelta(weeks=1))
birthdays = await crud.get_birthdays_on_day(postgres, datetime.today())
assert len(birthdays) == 1

View file

@ -7,7 +7,7 @@ from database.schemas import User
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)
await crud.get_or_add_user(postgres, 1)
statement = select(User)
res = (await postgres.execute(statement)).scalars().all()
@ -18,8 +18,8 @@ async def test_get_or_add_non_existing(postgres: AsyncSession):
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)
user = await crud.get_or_add_user(postgres, 1)
bank = user.bank
assert await crud.get_or_add(postgres, 1) == user
assert (await crud.get_or_add(postgres, 1)).bank == bank
assert await crud.get_or_add_user(postgres, 1) == user
assert (await crud.get_or_add_user(postgres, 1)).bank == bank