فهرست منبع

Added model unit tests

Vsevolod Levitan 1 سال پیش
والد
کامیت
7b4d440a9a
1فایلهای تغییر یافته به همراه73 افزوده شده و 0 حذف شده
  1. 73 0
      tests/test_models.py

+ 73 - 0
tests/test_models.py

@@ -0,0 +1,73 @@
+import unittest
+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(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()
+        fn = "abc"
+        nom = nomenclature_model(fn, munit, None)
+    
+        # Действие
+        
+    
+        # Проверка
+        assert isinstance(nom, nomenclature_model)
+        assert nom.full_name == fn
+        
+    def test_base_name_validation(self):
+        # Подготовка
+        some = abstract_reference()
+        fn = "abc"
+    
+        # Действие
+        some.name = fn
+    
+        # Проверка
+        self.assertRaises(argument_exception, some.name(""))
+        self.assertRaises(argument_exception, some.name(" " * 51))
+        self.assertRaises(argument_exception, 10)
+        assert some.name == fn
+    
+