generated from coulomb/repo-seed
Port e2e-framework schema, runner, and reporter into wise-validator with sand-boxer CLI integration, validate run CLI, unit tests, registry capability, and operator docs.
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""State Hub reporter tests."""
|
|
|
|
import json
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from wisevalidator.models import RunResult
|
|
from wisevalidator.reporter import report
|
|
|
|
|
|
def test_report_posts_e2e_result() -> None:
|
|
result = RunResult(
|
|
sandbox_id="abc12345",
|
|
repo="fixture-repo",
|
|
passed=True,
|
|
exit_code=0,
|
|
duration_s=12.3,
|
|
output="ok",
|
|
)
|
|
captured: dict = {}
|
|
|
|
def fake_urlopen(req, timeout=10):
|
|
captured["url"] = req.full_url
|
|
captured["body"] = json.loads(req.data.decode())
|
|
resp = MagicMock()
|
|
resp.status = 201
|
|
resp.__enter__ = MagicMock(return_value=resp)
|
|
resp.__exit__ = MagicMock(return_value=False)
|
|
return resp
|
|
|
|
with patch("wisevalidator.reporter.urllib.request.urlopen", fake_urlopen):
|
|
ok = report(result, workstream_id="ws-uuid")
|
|
|
|
assert ok is True
|
|
assert captured["url"].endswith("/progress/")
|
|
assert captured["body"]["event_type"] == "e2e_result"
|
|
assert "PASSED" in captured["body"]["summary"]
|
|
assert captured["body"]["workstream_id"] == "ws-uuid" |