46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
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.content_marketing import (
|
|
CONTENT_RESOURCE,
|
|
CONTENT_SCHEDULED_WORKFLOW_IDS,
|
|
CONTENT_TIMEOUT_SECONDS,
|
|
CONTENT_WORKFLOW_IDS,
|
|
ContentMarketingModule,
|
|
)
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_content_module_registers_only_scheduled_entries() -> None:
|
|
module = ContentMarketingModule.from_catalog(
|
|
WorkflowCatalog.load(PROJECT_ROOT / "config")
|
|
)
|
|
|
|
definitions = module.workflow_definitions()
|
|
assert tuple(item.workflow_id for item in definitions) == CONTENT_WORKFLOW_IDS
|
|
assert len(CONTENT_SCHEDULED_WORKFLOW_IDS) == 8
|
|
|
|
|
|
def test_content_workflows_use_project_owned_module_commands() -> None:
|
|
module = ContentMarketingModule.from_catalog(
|
|
WorkflowCatalog.load(PROJECT_ROOT / "config")
|
|
)
|
|
|
|
for definition in module.workflow_definitions():
|
|
assert definition.steps
|
|
for step in definition.steps:
|
|
assert isinstance(step.action, DeferredModuleCommandStep)
|
|
assert step.timeout_seconds == CONTENT_TIMEOUT_SECONDS == 4 * 60 * 60
|
|
assert step.max_attempts == 1
|
|
if definition.workflow_id == "content.comments.weekly":
|
|
assert step.resources == (f"{CONTENT_RESOURCE}:{step.step_id}",)
|
|
else:
|
|
assert step.resources == (CONTENT_RESOURCE,) == (
|
|
"module:content_marketing",
|
|
)
|
|
assert step.production_sink is True
|