2022-07-18 20:00:39 +00:00
|
|
|
from sqlalchemy import select
|
2022-07-27 19:10:43 +00:00
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
2022-07-18 20:00:39 +00:00
|
|
|
|
|
|
|
from database.crud import dad_jokes as crud
|
2022-07-25 19:20:09 +00:00
|
|
|
from database.schemas.relational import DadJoke
|
2022-07-18 20:00:39 +00:00
|
|
|
|
|
|
|
|
2022-07-27 19:10:43 +00:00
|
|
|
async def test_add_dad_joke(postgres: AsyncSession):
|
2022-07-18 20:00:39 +00:00
|
|
|
"""Test creating a new joke"""
|
|
|
|
statement = select(DadJoke)
|
2022-07-25 17:12:27 +00:00
|
|
|
result = (await postgres.execute(statement)).scalars().all()
|
2022-07-18 20:00:39 +00:00
|
|
|
assert len(result) == 0
|
|
|
|
|
2022-07-25 17:12:27 +00:00
|
|
|
await crud.add_dad_joke(postgres, "joke")
|
|
|
|
result = (await postgres.execute(statement)).scalars().all()
|
2022-07-18 20:00:39 +00:00
|
|
|
assert len(result) == 1
|