Add VedAstro adapter request contract
This commit is contained in:
@@ -57,13 +57,25 @@ PARITY_CASES = {
|
||||
},
|
||||
}
|
||||
|
||||
DEFAULT_TIMEOUT_SECONDS = 8
|
||||
RETRY_POLICY = {
|
||||
"max_attempts": 2,
|
||||
"backoff_seconds": 1,
|
||||
"retry_on": ["timeout", "429", "502", "503", "504"],
|
||||
}
|
||||
|
||||
|
||||
def schema() -> dict[str, Any]:
|
||||
request_example = {
|
||||
**PARITY_CASES["beijing_first_use_demo"],
|
||||
"body_list": ["Sun", "Moon", "Ascendant", "Rahu", "Ketu"],
|
||||
}
|
||||
return {
|
||||
"adapter": "vedastro_service_adapter",
|
||||
"backend": "vedastro_service_adapter_candidate",
|
||||
"transport": "http_json_service_boundary",
|
||||
"default_timeout_seconds": 8,
|
||||
"default_timeout_seconds": DEFAULT_TIMEOUT_SECONDS,
|
||||
"retry_policy": RETRY_POLICY,
|
||||
"required_env": {
|
||||
"endpoint": "VEDASTRO_API_ENDPOINT",
|
||||
"api_key_optional": "VEDASTRO_API_KEY",
|
||||
@@ -91,6 +103,17 @@ def schema() -> dict[str, Any]:
|
||||
"bodies",
|
||||
"source_metadata",
|
||||
],
|
||||
"request_example": request_example,
|
||||
"provenance_contract": {
|
||||
"external_service": True,
|
||||
"required_fields": [
|
||||
"endpoint",
|
||||
"transport",
|
||||
"provenance_mode",
|
||||
"retry_policy",
|
||||
"timeout_seconds",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +127,9 @@ def _unconfigured(reason: str) -> dict[str, Any]:
|
||||
"transport": "http_json_service_boundary",
|
||||
"endpoint_env": "VEDASTRO_API_ENDPOINT",
|
||||
"api_key_env": "VEDASTRO_API_KEY",
|
||||
"provenance_mode": "external_service_candidate",
|
||||
"timeout_seconds": DEFAULT_TIMEOUT_SECONDS,
|
||||
"retry_policy": RETRY_POLICY,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -135,6 +161,8 @@ def run_case(case_id: str) -> dict[str, Any]:
|
||||
"transport": "http_json_service_boundary",
|
||||
"endpoint": endpoint,
|
||||
"provenance_mode": "external_service_candidate",
|
||||
"timeout_seconds": DEFAULT_TIMEOUT_SECONDS,
|
||||
"retry_policy": RETRY_POLICY,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,15 @@ def test_vedastro_service_adapter_executor_schema_is_declared() -> None:
|
||||
assert report["adapter"] == "vedastro_service_adapter"
|
||||
assert report["transport"] == "http_json_service_boundary"
|
||||
assert report["default_timeout_seconds"] >= 3
|
||||
assert report["retry_policy"]["max_attempts"] >= 1
|
||||
assert report["retry_policy"]["backoff_seconds"] >= 0
|
||||
assert "endpoint" in report["required_env"]
|
||||
assert "ayanamsa_policy" in report["request_contract"]
|
||||
assert "bodies" in report["response_contract"]
|
||||
assert "source_metadata" in report["response_contract"]
|
||||
assert "request_example" in report
|
||||
assert report["provenance_contract"]["external_service"] is True
|
||||
assert "endpoint" in report["provenance_contract"]["required_fields"]
|
||||
|
||||
|
||||
def test_vedastro_service_adapter_returns_controlled_unconfigured_status() -> None:
|
||||
@@ -46,6 +51,9 @@ def test_vedastro_service_adapter_returns_controlled_unconfigured_status() -> No
|
||||
assert report["available"] is False
|
||||
assert report["status"] == "service_endpoint_not_configured"
|
||||
assert "VEDASTRO" in report["reason"]
|
||||
assert report["source_metadata"]["transport"] == "http_json_service_boundary"
|
||||
assert report["source_metadata"]["retry_policy"]["max_attempts"] >= 1
|
||||
assert report["source_metadata"]["provenance_mode"] == "external_service_candidate"
|
||||
|
||||
|
||||
def test_ephemeris_adapter_contract_can_call_vedastro_candidate_stub() -> None:
|
||||
|
||||
Reference in New Issue
Block a user