Moved tests into folder
This commit is contained in:
parent
720bae6c22
commit
947dc21da7
3 changed files with 34 additions and 10 deletions
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
|
|
@ -80,6 +80,26 @@ class Products:
|
|||
raw_data={},
|
||||
)
|
||||
|
||||
apple = products.Product(
|
||||
id=0,
|
||||
name="Apple",
|
||||
product_id="0",
|
||||
link="https://www.woolworths.com.au/shop/productdetails/0/apple",
|
||||
img_small="https://cdn0.woolworths.media/content/wowproductimages/small/0.jpg",
|
||||
img_large="https://cdn0.woolworths.media/content/wowproductimages/large/0.jpg",
|
||||
raw_data={},
|
||||
)
|
||||
|
||||
banana = products.Product(
|
||||
id=0,
|
||||
name="Banana",
|
||||
product_id="0",
|
||||
link="https://www.woolworths.com.au/shop/productdetails/0/banana",
|
||||
img_small="https://cdn0.woolworths.media/content/wowproductimages/small/0.jpg",
|
||||
img_large="https://cdn0.woolworths.media/content/wowproductimages/large/0.jpg",
|
||||
raw_data={},
|
||||
)
|
||||
|
||||
_tags = {
|
||||
broccoli.product_id: ['broccoli', 'fresh broccoli'],
|
||||
garlic_bread.product_id: ['garlic bread', 'bread', 'garlic', 'frozen garlic bread'],
|
||||
|
|
@ -92,6 +112,16 @@ class Products:
|
|||
import ingredients
|
||||
|
||||
class Ingredients:
|
||||
one_apple = ingredients.Ingredient(
|
||||
id=0,
|
||||
line='1 Apple',
|
||||
name='Apple',
|
||||
unit='Items',
|
||||
quantity='1',
|
||||
preparation='',
|
||||
product=Products.apple,
|
||||
)
|
||||
|
||||
broccoli_chopped_1kg = ingredients.Ingredient(
|
||||
id=0,
|
||||
line='1kg Broccoli, Chopped',
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
import unittest
|
||||
import datetime
|
||||
|
||||
import test_data
|
||||
import tests.test_data as test_data
|
||||
import importlib
|
||||
|
||||
def reload_test_data():
|
||||
global test_data
|
||||
test_data = importlib.reload(test_data)
|
||||
|
||||
import pathlib
|
||||
from db import connect, create
|
||||
|
||||
import products.db as products_db
|
||||
|
|
@ -24,14 +23,13 @@ def unique(lst: list, key: callable):
|
|||
|
||||
class TestProducts(unittest.IsolatedAsyncioTestCase):
|
||||
async def asyncSetUp(self):
|
||||
self.conn = await connect('./testdb.db')
|
||||
self.conn = await connect(':memory:')
|
||||
await create(self.conn)
|
||||
reload_test_data()
|
||||
return await super().asyncSetUp()
|
||||
|
||||
async def asyncTearDown(self) -> None:
|
||||
await self.conn.close()
|
||||
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
||||
return await super().asyncTearDown()
|
||||
|
||||
async def testCreateAndFind(self) -> None:
|
||||
|
|
@ -52,8 +50,7 @@ import main
|
|||
|
||||
class TestRecipe(unittest.IsolatedAsyncioTestCase):
|
||||
async def asyncSetUp(self):
|
||||
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
||||
self.conn = await connect('./testdb.db')
|
||||
self.conn = await connect(':memory:')
|
||||
await create(self.conn)
|
||||
await test_data.create_persons(self.conn)
|
||||
reload_test_data()
|
||||
|
|
@ -62,7 +59,6 @@ class TestRecipe(unittest.IsolatedAsyncioTestCase):
|
|||
|
||||
async def asyncTearDown(self) -> None:
|
||||
await self.conn.close()
|
||||
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
||||
return await super().asyncTearDown()
|
||||
|
||||
async def testCreateAndFind(self) -> None:
|
||||
|
|
@ -118,8 +114,7 @@ import meals
|
|||
|
||||
class TestMeals(unittest.IsolatedAsyncioTestCase):
|
||||
async def asyncSetUp(self):
|
||||
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
||||
self.conn = await connect('./testdb.db')
|
||||
self.conn = await connect(':memory:')
|
||||
await create(self.conn)
|
||||
await test_data.create_persons(self.conn)
|
||||
reload_test_data()
|
||||
|
|
@ -127,7 +122,6 @@ class TestMeals(unittest.IsolatedAsyncioTestCase):
|
|||
|
||||
async def asyncTearDown(self) -> None:
|
||||
await self.conn.close()
|
||||
pathlib.Path('./testdb.db').unlink(missing_ok=True)
|
||||
return await super().asyncTearDown()
|
||||
|
||||
async def testMultiplePariticpants(self) -> None:
|
||||
Loading…
Reference in a new issue