"""Compatibility adapter coverage for RMGR-WP-0008-T01.""" from api.services import repo_manager_dual_run as adapter def test_rm_update_workplan_builds_governed_cli_command(monkeypatch): seen = {} def fake_run(args, *, timeout=120): seen["args"] = args return 0, '{"status":"applied","evidence":{"git_sha":"abc"}}', "" monkeypatch.setattr(adapter, "run_rmgr", fake_run) result = adapter.rm_update_workplan( repo_path="/repos/demo", workplan_id="DEMO-WP-0001", operation="update", title="Renamed", status="active", repo_slug="demo", correlation_id="00000000-0000-4000-8000-000000000001", push=True, ) assert result["status"] == "applied" assert seen["args"][:5] == [ "workplan", "update", "--path", "/repos/demo", "--workplan-id", ] assert "--title" in seen["args"] assert "--status" in seen["args"] assert "--push" in seen["args"] def test_rm_update_workplan_maps_delete_to_confirmed_archive(monkeypatch): seen = {} def fake_run(args, *, timeout=120): seen["args"] = args return 0, '{"status":"applied"}', "" monkeypatch.setattr(adapter, "run_rmgr", fake_run) result = adapter.rm_update_workplan( repo_path="/repos/demo", workplan_id="DEMO-WP-0001", operation="archive", confirm_archive=True, push=False, ) assert result["status"] == "applied" assert seen["args"][0:2] == ["workplan", "delete"] assert "--confirm" in seen["args"] assert "--push" not in seen["args"] def test_rm_update_workplan_rejects_unknown_operation_without_invocation(monkeypatch): def fail_run(*args, **kwargs): raise AssertionError("rmgr must not run") monkeypatch.setattr(adapter, "run_rmgr", fail_run) result = adapter.rm_update_workplan( repo_path="/repos/demo", workplan_id="DEMO-WP-0001", operation="erase", ) assert result["status"] == "rejected" assert result["error"]["code"] == "validation_error" def test_rm_update_register_entry_builds_shared_spine_command(monkeypatch): seen = {} def fake_run(args, *, timeout=120): seen["args"] = args return 0, '{"status":"applied"}', "" monkeypatch.setattr(adapter, "run_rmgr", fake_run) result = adapter.rm_update_register_entry( repo_path="/repos/demo", kind="technical-debt", entry_id="TD-001", operation="put", title="Debt", data={"severity": "high"}, push=False, ) assert result["status"] == "applied" assert seen["args"][0:2] == ["register", "put"] assert "technical-debt" in seen["args"] assert '{"severity":"high"}' in seen["args"]