26 lines
1021 B
Python
26 lines
1021 B
Python
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
|
|
def test_static_contract_is_openapi_31_and_redacted() -> None:
|
|
contract = yaml.safe_load(
|
|
(Path(__file__).parents[2] / "openapi.yaml").read_text(encoding="utf-8")
|
|
)
|
|
assert contract["openapi"] == "3.1.0"
|
|
paths = contract["paths"]
|
|
assert "/internal/sms/v1/send" in paths
|
|
assert "/internal/sms/v1/messages/{sms_message_id}" in paths
|
|
assert "/callbacks/idgtl/sms" in paths
|
|
message_fields = contract["components"]["schemas"]["Message"]["properties"]
|
|
assert {"phone_e164", "body_rendered", "substitutions"}.isdisjoint(message_fields)
|
|
assert "idgtlDeliveryStatus" in contract["webhooks"]
|
|
|
|
|
|
def test_send_contract_distinguishes_new_and_replayed_order() -> None:
|
|
contract = yaml.safe_load(
|
|
(Path(__file__).parents[2] / "openapi.yaml").read_text(encoding="utf-8")
|
|
)
|
|
responses = contract["paths"]["/internal/sms/v1/send"]["post"]["responses"]
|
|
assert {"200", "202", "401", "409", "422", "429", "503"} <= responses.keys()
|