Fixed bug in tests
This commit is contained in:
parent
9257466caa
commit
ea3635b8d6
2 changed files with 7 additions and 2 deletions
|
|
@ -192,6 +192,10 @@ class Meals:
|
||||||
def class_fields(obj):
|
def class_fields(obj):
|
||||||
return {k:v for k,v in obj.__dict__.items() if not k.startswith('_')}
|
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__':
|
if __name__ == '__main__':
|
||||||
import asyncio
|
import asyncio
|
||||||
from db import connect, create
|
from db import connect, create
|
||||||
|
|
@ -201,8 +205,7 @@ if __name__ == '__main__':
|
||||||
await create(conn)
|
await create(conn)
|
||||||
await conn.commit()
|
await conn.commit()
|
||||||
|
|
||||||
for person in class_fields(Persons).values():
|
await create_persons(conn)
|
||||||
await persons.insert_person(conn, person)
|
|
||||||
|
|
||||||
for product in class_fields(Products).values():
|
for product in class_fields(Products).values():
|
||||||
await products.insert_product(conn, product, {})
|
await products.insert_product(conn, product, {})
|
||||||
|
|
|
||||||
2
tests.py
2
tests.py
|
|
@ -39,6 +39,7 @@ class TestRecipe(unittest.IsolatedAsyncioTestCase):
|
||||||
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
||||||
self.conn = await connect('./testdb.db')
|
self.conn = await connect('./testdb.db')
|
||||||
await create(self.conn)
|
await create(self.conn)
|
||||||
|
await test_data.create_persons(self.conn)
|
||||||
return await super().asyncSetUp()
|
return await super().asyncSetUp()
|
||||||
|
|
||||||
async def asyncTearDown(self) -> None:
|
async def asyncTearDown(self) -> None:
|
||||||
|
|
@ -89,6 +90,7 @@ class TestMeals(unittest.IsolatedAsyncioTestCase):
|
||||||
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
||||||
self.conn = await connect('./testdb.db')
|
self.conn = await connect('./testdb.db')
|
||||||
await create(self.conn)
|
await create(self.conn)
|
||||||
|
await test_data.create_persons(self.conn)
|
||||||
return await super().asyncSetUp()
|
return await super().asyncSetUp()
|
||||||
|
|
||||||
async def asyncTearDown(self) -> None:
|
async def asyncTearDown(self) -> None:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue