chore: [workflow] 提交工作区改动

This commit is contained in:
2026-09-07 15:14:54 +08:00
parent 485e77ee74
commit 2ff588a65d
27 changed files with 373 additions and 138 deletions
+23 -18
View File
@@ -11,15 +11,15 @@ from gyxx_flow.catalog import CatalogError, WorkflowCatalog
PROJECT_ROOT = Path(__file__).resolve().parents[1]
def test_catalog_maps_27_project_scheduled_tasks() -> None:
def test_catalog_maps_29_project_scheduled_tasks() -> None:
catalog = WorkflowCatalog.load(PROJECT_ROOT / "config")
scheduled = catalog.scheduled_workflows()
assert len(scheduled) == 27
assert len({item.source_task_name for item in scheduled}) == 27
assert len(scheduled) == 29
assert len({item.source_task_name for item in scheduled}) == 29
assert Counter(item.module for item in scheduled) == {
"content_marketing": 9,
"product_commerce": 10,
"product_commerce": 12,
"shop_intelligence": 4,
"supply_chain": 4,
}
@@ -30,10 +30,7 @@ def test_catalog_schedules_douyin_price_appeal() -> None:
schedule = catalog.schedule_for("shop.douyin_price_appeal")
assert len(catalog.workflows) == 29
assert tuple(item.workflow_id for item in catalog.manual_workflows()) == (
"product.video_upload",
"product.jd_video_upload",
)
assert catalog.manual_workflows() == ()
assert "shop.douyin_price_appeal" in {
schedule.workflow_id for schedule in catalog.schedules
}
@@ -42,13 +39,13 @@ def test_catalog_schedules_douyin_price_appeal() -> None:
assert schedule.effective_times == ("08:00", "16:00", "22:00")
def test_tmall_video_upload_is_an_idempotent_store_selected_manual_workflow() -> None:
def test_tmall_video_upload_is_an_idempotent_store_selected_scheduled_workflow() -> None:
catalog = WorkflowCatalog.load(PROJECT_ROOT / "config")
workflow = next(
item for item in catalog.workflows if item.workflow_id == "product.video_upload"
)
assert workflow.trigger == "manual"
assert workflow.trigger == "scheduled"
assert [step.step_id for step in workflow.steps] == ["upload"]
step = workflow.steps[0]
assert step.entry == "upload_video_to_guanghe.py"
@@ -60,11 +57,15 @@ def test_tmall_video_upload_is_an_idempotent_store_selected_manual_workflow() ->
assert step.timeout_seconds == 21600
assert workflow.topic_config is not None
assert workflow.topic_config.default_keyword == "我的夏日焕新清单"
with pytest.raises(KeyError):
catalog.schedule_for(workflow.workflow_id)
schedule = catalog.schedule_for(workflow.workflow_id)
assert schedule.kind == "interval_days"
assert schedule.at == "14:00"
assert schedule.every_days == 3
assert schedule.anchor_date == "2026-09-04"
assert schedule.enabled is True
def test_jd_video_upload_is_an_idempotent_manual_workflow() -> None:
def test_jd_video_upload_is_an_idempotent_scheduled_workflow() -> None:
catalog = WorkflowCatalog.load(PROJECT_ROOT / "config")
workflow = next(
item
@@ -72,7 +73,7 @@ def test_jd_video_upload_is_an_idempotent_manual_workflow() -> None:
if item.workflow_id == "product.jd_video_upload"
)
assert workflow.trigger == "manual"
assert workflow.trigger == "scheduled"
assert [step.step_id for step in workflow.steps] == ["upload"]
step = workflow.steps[0]
assert step.entry == "upload_video_to_jd.py"
@@ -84,8 +85,12 @@ def test_jd_video_upload_is_an_idempotent_manual_workflow() -> None:
)
assert step.replay_policy == "idempotent"
assert step.timeout_seconds == 21600
with pytest.raises(KeyError):
catalog.schedule_for(workflow.workflow_id)
schedule = catalog.schedule_for(workflow.workflow_id)
assert schedule.kind == "interval_days"
assert schedule.at == "14:00"
assert schedule.every_days == 3
assert schedule.anchor_date == "2026-09-04"
assert schedule.enabled is True
def test_tmall_baibu_apply_is_a_six_step_hourly_workflow() -> None:
@@ -181,13 +186,13 @@ def test_every_scheduled_workflow_has_one_valid_asia_shanghai_schedule() -> None
catalog = WorkflowCatalog.load(PROJECT_ROOT / "config")
assert catalog.timezone == "Asia/Shanghai"
assert len(catalog.schedules) == 27
assert len(catalog.schedules) == 29
for workflow in catalog.scheduled_workflows():
schedule = catalog.schedule_for(workflow.workflow_id)
assert schedule.workflow_id == workflow.workflow_id
assert schedule.kind in {"daily", "weekly", "monthly", "interval_days"}
assert schedule.at.count(":") == 1
assert sum(schedule.enabled for schedule in catalog.schedules) == 23
assert sum(schedule.enabled for schedule in catalog.schedules) == 25
def test_scheduled_workflows_use_python_entries_and_content_tasks_are_graphs() -> None: