from __future__ import annotations from pathlib import Path from gyxx_flow.adapters.native import DeferredModuleCommandStep from gyxx_flow.catalog import WorkflowCatalog from gyxx_flow.modules.supply_chain import ( MANUAL_SUPPLY_WORKFLOW_IDS, SCHEDULED_SUPPLY_WORKFLOW_IDS, SUPPLY_RESOURCE, SUPPLY_TIMEOUT_SECONDS, SUPPLY_WORKFLOW_IDS, SupplyChainModule, ) PROJECT_ROOT = Path(__file__).resolve().parents[1] def test_supply_module_registers_scheduled_and_manual_workflows() -> None: module = SupplyChainModule.from_catalog( WorkflowCatalog.load(PROJECT_ROOT / "config") ) assert tuple(item.workflow_id for item in module.workflow_definitions()) == SUPPLY_WORKFLOW_IDS assert len(SCHEDULED_SUPPLY_WORKFLOW_IDS) == 3 assert len(MANUAL_SUPPLY_WORKFLOW_IDS) == 1 def test_supply_workflows_use_project_owned_module_commands() -> None: module = SupplyChainModule.from_catalog( WorkflowCatalog.load(PROJECT_ROOT / "config") ) for definition in module.workflow_definitions(): step = definition.steps[0] assert step.step_id == "module_supply" assert isinstance(step.action, DeferredModuleCommandStep) assert step.timeout_seconds == SUPPLY_TIMEOUT_SECONDS == 2 * 60 * 60 assert step.max_attempts == 1 assert step.resources == (SUPPLY_RESOURCE,) == ("module:supply_chain",) assert step.production_sink is True