Fixed bug in tests

This commit is contained in:
jableader 2024-04-28 13:42:21 +10:00
parent 9257466caa
commit ea3635b8d6
2 changed files with 7 additions and 2 deletions

View file

@ -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, {})

View file

@ -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: