tests: ensure we actually commit given data to the database
This commit is contained in:
parent
d205f4909e
commit
a4df79cda3
1 changed files with 15 additions and 0 deletions
15
tests.py
15
tests.py
|
|
@ -1,3 +1,4 @@
|
|||
import uuid
|
||||
from typing import Generator, Sequence
|
||||
|
||||
import pytest
|
||||
|
|
@ -9,6 +10,7 @@ from teilchensammler_cli.models import (
|
|||
TeilchenCreate,
|
||||
load_initial_data,
|
||||
make_teilchen_input,
|
||||
add_to_database,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -155,3 +157,16 @@ async def test_loadinitialdata_returns_expected_data(engine: Engine, db_teilchen
|
|||
fetched_teilchen = Teilchen.model_validate(teilchen_data)
|
||||
|
||||
assert fetched_teilchen == db_teilchen
|
||||
|
||||
|
||||
async def test_data_provided_to_addtodatabase_ends_up_in_database(engine: Engine):
|
||||
all_data = await load_initial_data(engine)
|
||||
assert len(all_data) == 0
|
||||
|
||||
teilchen = Teilchen(
|
||||
id=uuid.uuid7(), name="test", description="test", tags="#test", number=1, text="test"
|
||||
)
|
||||
|
||||
db_teilchen = await add_to_database(teilchen, engine)
|
||||
|
||||
assert teilchen == db_teilchen
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue