123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import unittest
- from src.models.ingredient_model import ingredient_model
- from src.models.recipe_model import recipe_model
- from src.models.company_model import company_model
- from src.settings.settings_manager import settings_manager
- from src.models.measurement_unit_model import measurement_unit_model
- from src.models.nomenclature_group_model import nomenclature_group_model
- from src.models.nomenclature_model import nomenclature_model
- from src.models.warehouse_model import warehouse_model
- from src.models.abstract_reference import abstract_reference
- from src.errors.argument_exception import argument_exception
- from os import path
- class test_models(unittest.TestCase):
- def test_company(self):
- # Подготовка
- setman = settings_manager()
- setman.open(path.dirname(__file__) + "/../config/settings.json")
- sts = setman.settings
-
- # Действие
- company = company_model("Test company", sts)
-
- # Проверка
- assert isinstance(company, company_model)
- print("c", company.tax_id)
- print("s", sts.tax_id)
- assert company.tax_id == sts.tax_id
- assert company.bank_id == sts.bank_id
- assert company.bank_account_id == sts.bank_account_id
- assert company.property_type == sts.property_type
-
- def test_measurement_unit(self):
- # Подготовка
- g = measurement_unit_model("Граммы")
- kg = measurement_unit_model("Килограммы", 1000, g)
-
- # Действие
-
-
- # Проверка
- assert isinstance(g, measurement_unit_model)
- assert isinstance(kg, measurement_unit_model)
- assert g.to_base_unit(1) == 1
- assert kg.to_base_unit(1) == 1000
- def test_nomenclature(self):
- # Подготовка
- munit = measurement_unit_model("Test munit")
- fn = "abc"
- nom = nomenclature_model("Test nomenclature", fn, munit, nomenclature_group_model("Test ng"))
-
- # Действие
-
-
- # Проверка
- assert isinstance(nom, nomenclature_model)
- assert nom.full_name == fn
- def test_ingredient(self):
- # Подготовка
- munit = measurement_unit_model.create_g()
- nom = nomenclature_model("A", "A", munit, nomenclature_group_model("group"))
- amount = 10
- ingredient = ingredient_model("Тест", nom, amount, munit)
- # Действие
- # Проверка
- assert isinstance(ingredient, ingredient_model)
- assert ingredient.amount == amount
- assert ingredient.nomenclature == nom
- assert ingredient.measurement_unit == munit
- def test_recipe(self):
- # Подготовка
- munit = measurement_unit_model.create_g()
- nom = nomenclature_model("A", "A", munit, nomenclature_group_model("group"))
- nom2 = nomenclature_model("B", "B", munit, nomenclature_group_model("group"))
- amount = 10
- ingredient = ingredient_model("Тест", nom, amount, munit)
- ingredient2 = ingredient_model("Тест", nom2, amount, munit)
- steps = ["Aaaa.", "Bbbb."]
- recipe = recipe_model("Тест", [ingredient, ingredient2], steps)
- # Действие
- # Проверка
- assert isinstance(recipe, recipe_model)
- assert len(recipe.ingredients) == 2
- assert recipe.ingredients[0] == ingredient
- assert recipe.ingredients[1] == ingredient2
- assert len(recipe.steps) == 2
- assert recipe.steps[0] == steps[0]
- assert recipe.steps[1] == steps[1]
-
- def test_base_name_validation(self):
- # Подготовка
- fn = "abc"
- some = abstract_reference(fn)
- fn *= 2
-
- # Действие
- some.name = fn
-
- # Проверка
- assert some.name == fn
-
-
|