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