Ver código fonte

Added tests for ingredient_model and recipe_model

Vsevolod Levitan 1 ano atrás
pai
commit
5c76156e2e
1 arquivos alterados com 41 adições e 0 exclusões
  1. 41 0
      tests/test_models.py

+ 41 - 0
tests/test_models.py

@@ -1,4 +1,6 @@
 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
@@ -55,6 +57,45 @@ class test_models(unittest.TestCase):
         # Проверка
         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):
         # Подготовка