mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Fix broken migration
This commit is contained in:
parent
8bc0f1fa7a
commit
66997b7556
6 changed files with 17 additions and 7 deletions
|
|
@ -23,7 +23,7 @@ def event_loop() -> Generator:
|
|||
|
||||
@pytest.fixture(scope="session")
|
||||
async def tables():
|
||||
"""Initialize a database before the tests, and then tear it down again
|
||||
"""Fixture to initialize a database before the tests, and then tear it down again
|
||||
|
||||
Checks that the migrations were successful by asserting that we are currently
|
||||
on the latest migration
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ async def test_add_birthday_not_present(database_session: AsyncSession, user: Us
|
|||
await crud.add_birthday(database_session, user.user_id, bd_date)
|
||||
await database_session.refresh(user)
|
||||
assert user.birthday is not None
|
||||
assert user.birthday.birthday.date() == bd_date
|
||||
assert user.birthday.birthday == bd_date
|
||||
|
||||
|
||||
async def test_add_birthday_overwrite(database_session: AsyncSession, user: User):
|
||||
|
|
@ -27,7 +27,7 @@ async def test_add_birthday_overwrite(database_session: AsyncSession, user: User
|
|||
new_bd_date = bd_date + timedelta(weeks=1)
|
||||
await crud.add_birthday(database_session, user.user_id, new_bd_date)
|
||||
await database_session.refresh(user)
|
||||
assert user.birthday.birthday.date() == new_bd_date
|
||||
assert user.birthday.birthday == new_bd_date
|
||||
|
||||
|
||||
async def test_get_birthday_exists(database_session: AsyncSession, user: User):
|
||||
|
|
@ -38,7 +38,7 @@ async def test_get_birthday_exists(database_session: AsyncSession, user: User):
|
|||
|
||||
bd = await crud.get_birthday_for_user(database_session, user.user_id)
|
||||
assert bd is not None
|
||||
assert bd.birthday.date() == bd_date
|
||||
assert bd.birthday == bd_date
|
||||
|
||||
|
||||
async def test_get_birthday_not_exists(database_session: AsyncSession, user: User):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import datetime
|
||||
|
||||
import pytest
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.crud import currency as crud
|
||||
|
|
@ -14,13 +17,18 @@ async def test_add_dinks(database_session: AsyncSession, bank: Bank):
|
|||
assert bank.dinks == 10
|
||||
|
||||
|
||||
@freeze_time("2022/07/23")
|
||||
async def test_claim_nightly_available(database_session: AsyncSession, bank: Bank):
|
||||
"""Test claiming nightlies when it hasn't been done yet"""
|
||||
await crud.claim_nightly(database_session, bank.user_id)
|
||||
await database_session.refresh(bank)
|
||||
assert bank.dinks == crud.NIGHTLY_AMOUNT
|
||||
|
||||
nightly_data = await crud.get_nightly_data(database_session, bank.user_id)
|
||||
assert nightly_data.last_nightly == datetime.date(year=2022, month=7, day=23)
|
||||
|
||||
|
||||
@freeze_time("2022/07/23")
|
||||
async def test_claim_nightly_unavailable(database_session: AsyncSession, bank: Bank):
|
||||
"""Test claiming nightlies twice in a day"""
|
||||
await crud.claim_nightly(database_session, bank.user_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue