feat: expand module workflows, dynamic config, notifications and console API
This commit is contained in:
@@ -7,6 +7,7 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from gyxx_flow.adapters import WORKFLOW_ACCEPTANCE_RECIPIENT_OPEN_ID
|
||||
from gyxx_flow.notification_routing import ANALYZER_ACCEPTANCE_RECIPIENT_OPEN_ID
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -73,23 +74,71 @@ def test_replenishment_bitable_run_is_physically_skipped(
|
||||
def test_supply_card_sender_forces_only_wang_yunlong(
|
||||
acceptance_environment: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
module = importlib.import_module(
|
||||
"gyxx_flow.modules.supply_chain.orchestrator.scripts."
|
||||
"send_card_notification"
|
||||
)
|
||||
monkeypatch.setattr(module, "STATE_ROOT", tmp_path)
|
||||
run_id = "acceptance-run"
|
||||
snapshot_path = module._notification_snapshot_path("replenishment", run_id)
|
||||
snapshot_path.parent.mkdir(parents=True)
|
||||
snapshot_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"schema_version": 1,
|
||||
"workflow": "replenishment",
|
||||
"run_id": run_id,
|
||||
"enabled": True,
|
||||
"recipients": [ANALYZER_ACCEPTANCE_RECIPIENT_OPEN_ID],
|
||||
"acceptance": True,
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
sent: list[str] = []
|
||||
monkeypatch.setattr(module, "_get_tenant_token", lambda: "test-token")
|
||||
monkeypatch.setattr(
|
||||
module,
|
||||
"_send_card",
|
||||
lambda _token, open_id, _card: sent.append(open_id) or "mid-1",
|
||||
lambda open_id, _card, _key: sent.append(open_id) or "om_acceptance1",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
module.pg_writer,
|
||||
"mark_notification_sent",
|
||||
lambda *_args, **_kwargs: None,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
module.pg_writer,
|
||||
"notification_already_sent",
|
||||
lambda *_args, **_kwargs: True,
|
||||
)
|
||||
|
||||
result = module.run(["ou_other", "oc_group"], {"elements": []})
|
||||
with pytest.raises(RuntimeError, match="snapshot mismatch"):
|
||||
module.run(
|
||||
["ou_other123"],
|
||||
{"elements": []},
|
||||
workflow="replenishment",
|
||||
run_id=run_id,
|
||||
idempotency_key="replenishment:acceptance-run",
|
||||
)
|
||||
|
||||
assert sent == [WORKFLOW_ACCEPTANCE_RECIPIENT_OPEN_ID]
|
||||
assert result == {"message_ids": ["mid-1"], "errors": []}
|
||||
result = module.run(
|
||||
[ANALYZER_ACCEPTANCE_RECIPIENT_OPEN_ID],
|
||||
{"elements": []},
|
||||
workflow="replenishment",
|
||||
run_id=run_id,
|
||||
idempotency_key="replenishment:acceptance-run",
|
||||
)
|
||||
|
||||
assert sent == [ANALYZER_ACCEPTANCE_RECIPIENT_OPEN_ID]
|
||||
assert result == {
|
||||
"message_ids": ["om_acceptance1"],
|
||||
"recipient_message_ids": {
|
||||
ANALYZER_ACCEPTANCE_RECIPIENT_OPEN_ID: "om_acceptance1",
|
||||
},
|
||||
"errors": [],
|
||||
}
|
||||
|
||||
|
||||
def test_supply_config_uses_the_two_local_hermes_api_servers(
|
||||
|
||||
Reference in New Issue
Block a user