fix nested dicts, add more real life fastapi tests

This commit is contained in:
collerek
2020-08-15 12:37:48 +02:00
parent 3232c99fca
commit a0ad85811b
9 changed files with 161 additions and 26 deletions

View File

@ -61,7 +61,7 @@ class Teacher(ormar.Model):
category = ormar.ForeignKey(Category, nullable=True)
@pytest.fixture(scope='module')
@pytest.fixture(scope="module")
def event_loop():
loop = asyncio.get_event_loop()
yield loop
@ -92,6 +92,8 @@ async def test_model_multiple_instances_of_same_table_in_schema():
assert classes[0].name == "Math"
assert classes[0].students[0].name == "Jane"
assert len(classes[0].dict().get("students")) == 2
# related fields of main model are only populated by pk
# unless there is a required foreign key somewhere along the way
# since department is required for schoolclass it was pre loaded (again)