Files
crank/tests/unit/test_authenticated_product_smoke.py
T
github-ops 8096502bda
Deploy / deploy (push) Successful in 29s
CI / Rust Checks (push) Successful in 4m50s
CI / UI Checks (push) Successful in 5s
CI / Deployment Manifests (push) Successful in 2s
CI / Frontend E2E (push) Successful in 4m13s
Add deterministic product smoke
2026-06-20 18:07:57 +00:00

55 lines
1.9 KiB
Python

import importlib.util
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
SMOKE = ROOT / "scripts" / "authenticated-product-smoke.py"
def load_smoke_module():
spec = importlib.util.spec_from_file_location("authenticated_product_smoke", SMOKE)
module = importlib.util.module_from_spec(spec)
assert spec.loader is not None
spec.loader.exec_module(module)
return module
class AuthenticatedProductSmokeTests(unittest.TestCase):
def test_operation_payload_uses_internal_upstream(self) -> None:
smoke = load_smoke_module()
payload = smoke.build_operation_payload(
name="internal_health_smoke_123",
upstream_base_url="http://admin-api:3001",
)
self.assertEqual(payload["protocol"], "rest")
self.assertEqual(payload["target"]["method"], "GET")
self.assertEqual(payload["target"]["base_url"], "http://admin-api:3001")
self.assertEqual(payload["target"]["path_template"], "/health")
self.assertNotIn("open-meteo", str(payload).lower())
self.assertNotIn("frankfurter", str(payload).lower())
def test_public_mcp_url_keeps_proxy_prefix(self) -> None:
smoke = load_smoke_module()
self.assertEqual(
smoke.agent_mcp_url("https://crank.example.com/", "default", "health-smoke"),
"https://crank.example.com/mcp/v1/default/health-smoke",
)
def test_tool_call_payload_targets_health_tool(self) -> None:
smoke = load_smoke_module()
payload = smoke.tools_call_payload("internal_health_smoke", {"probe": "ok"})
self.assertEqual(payload["jsonrpc"], "2.0")
self.assertEqual(payload["method"], "tools/call")
self.assertEqual(payload["params"]["name"], "internal_health_smoke")
self.assertEqual(payload["params"]["arguments"], {"probe": "ok"})
if __name__ == "__main__":
unittest.main()