didier/tests/test_database/test_crud/test_dad_jokes.py

17 lines
526 B
Python
Raw Normal View History

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-07-25 21:20:09 +02:00
from database.schemas.relational 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