test_models.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import unittest
  2. from src.models.company_model import company_model
  3. from src.settings.settings_manager import settings_manager
  4. from src.models.measurement_unit_model import measurement_unit_model
  5. from src.models.nomenclature_group_model import nomenclature_group_model
  6. from src.models.nomenclature_model import nomenclature_model
  7. from src.models.warehouse_model import warehouse_model
  8. from src.models.abstract_reference import abstract_reference
  9. from src.errors.argument_exception import argument_exception
  10. from os import path
  11. class test_models(unittest.TestCase):
  12. def test_company(self):
  13. # Подготовка
  14. setman = settings_manager()
  15. setman.open(path.dirname(__file__) + "/../config/settings.json")
  16. sts = setman.settings
  17. # Действие
  18. company = company_model("Test company", sts)
  19. # Проверка
  20. assert isinstance(company, company_model)
  21. assert company.tax_id == sts.tax_id
  22. assert company.bank_id == sts.bank_id
  23. assert company.bank_account_id == sts.bank_account_id
  24. assert company.property_type == sts.property_type
  25. def test_measurement_unit(self):
  26. # Подготовка
  27. g = measurement_unit_model("Граммы")
  28. kg = measurement_unit_model("Килограммы", 1000, g)
  29. # Действие
  30. # Проверка
  31. assert isinstance(g, measurement_unit_model)
  32. assert isinstance(kg, measurement_unit_model)
  33. assert g.to_base_unit(1) == 1
  34. assert kg.to_base_unit(1) == 1000
  35. def test_nomenclature(self):
  36. # Подготовка
  37. munit = measurement_unit_model("Test munit")
  38. fn = "abc"
  39. nom = nomenclature_model("Test nomenclature", fn, munit, nomenclature_group_model("Test ng"))
  40. # Действие
  41. # Проверка
  42. assert isinstance(nom, nomenclature_model)
  43. assert nom.full_name == fn
  44. def test_warehouse(self):
  45. pass
  46. def test_nomenclature_group(self):
  47. pass
  48. def test_base_name_validation(self):
  49. # Подготовка
  50. fn = "abc"
  51. some = abstract_reference(fn)
  52. fn *= 2
  53. # Действие
  54. some.name = fn
  55. # Проверка
  56. assert some.name == fn