fix tests

This commit is contained in:
collerek
2020-12-10 16:27:19 +01:00
parent f4aedbfb2b
commit 099615c690

View File

@ -49,6 +49,8 @@ def create_test_database():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_create_models(): async def test_create_models():
async with db:
async with db.transaction(force_rollback=True):
primary = await PrimaryModel( primary = await PrimaryModel(
name="Foo", some_text="Bar", some_other_text="Baz" name="Foo", some_text="Bar", some_other_text="Baz"
).save() ).save()
@ -58,10 +60,7 @@ async def test_create_models():
assert secondary.id == 1 assert secondary.id == 1
assert secondary.primary_model.id == 1 assert secondary.primary_model.id == 1
secondary = await SecondaryModel.objects.get()
@pytest.mark.asyncio
async def test_update_secondary():
secondary = await SecondaryModel.objects.get(id=1)
assert secondary.name == "Foo" assert secondary.name == "Foo"
await secondary.update(name="Updated") await secondary.update(name="Updated")
assert secondary.name == "Updated" assert secondary.name == "Updated"