diff --git a/test_data.py b/test_data.py index 419920f..42a18ab 100644 --- a/test_data.py +++ b/test_data.py @@ -192,6 +192,10 @@ class Meals: def class_fields(obj): return {k:v for k,v in obj.__dict__.items() if not k.startswith('_')} +async def create_persons(conn): + for person in class_fields(Persons).values(): + await persons.insert_person(conn, person) + if __name__ == '__main__': import asyncio from db import connect, create @@ -201,8 +205,7 @@ if __name__ == '__main__': await create(conn) await conn.commit() - for person in class_fields(Persons).values(): - await persons.insert_person(conn, person) + await create_persons(conn) for product in class_fields(Products).values(): await products.insert_product(conn, product, {}) diff --git a/tests.py b/tests.py index f612469..088a531 100644 --- a/tests.py +++ b/tests.py @@ -39,6 +39,7 @@ class TestRecipe(unittest.IsolatedAsyncioTestCase): pathlib.Path('./testdb.db').unlink(missing_ok=True) self.conn = await connect('./testdb.db') await create(self.conn) + await test_data.create_persons(self.conn) return await super().asyncSetUp() async def asyncTearDown(self) -> None: @@ -89,6 +90,7 @@ class TestMeals(unittest.IsolatedAsyncioTestCase): pathlib.Path('./testdb.db').unlink(missing_ok=True) self.conn = await connect('./testdb.db') await create(self.conn) + await test_data.create_persons(self.conn) return await super().asyncSetUp() async def asyncTearDown(self) -> None: