from src.models.recipe_model import recipe_model 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.storage.storage_prototype import storage_prototype from src.logic.start_factory import start_factory from src.settings.settings_manager import settings_manager from src.storage.storage import storage from datetime import datetime import unittest class test_prototype(unittest.TestCase): def test_prototype(self): """Проверить работу storage_prototype при фильтровании по дате""" manager = settings_manager() strg = storage() start = start_factory(manager.settings, strg) start.create() key = storage.transaction_key() data = start.storage.data[key] prototype = storage_prototype(data) start_date = datetime.strptime("2024-01-01", "%Y-%m-%d") stop_date = datetime.strptime("2024-01-10", "%Y-%m-%d") result = prototype.filter_dt(start_date, stop_date) assert isinstance(result, storage_prototype) def test_nomenclature(self): """Проверить работу storage_prototype при фильтровании по номенклатуре""" manager = settings_manager() strg = storage() start = start_factory(manager.settings, strg) start.create() key = storage.transaction_key() data = start.storage.data[key] prototype = storage_prototype(data) nom = nomenclature_model( "test", "Test", measurement_unit_model("unit"), nomenclature_group_model.create_group(), ) result = prototype.filter_nom(nom) assert isinstance(result, storage_prototype) def test_recipe(self): """Проверить работу storage_prototype при фильтровании по рецепту""" manager = settings_manager() strg = storage() start = start_factory(manager.settings, strg) start.create() key = storage.transaction_key() data = start.storage.data[key] prototype = storage_prototype(data) recipe = recipe_model("Test") result = prototype.filter_recipe(recipe) assert isinstance(result, storage_prototype)