Files
nova-platform/tests/test_contract_schema.py
CIAgent 2443909362 docs(milestone): complete v1.0-nova-platform (release v0.1.6)
---ci---
project: nova-platform
milestone: v1.0
status: complete
requirements:
  covered: [REQ-01,REQ-02,REQ-03,REQ-04,REQ-05,REQ-06,REQ-07,REQ-08,REQ-09,REQ-10,REQ-11,REQ-12,REQ-13,REQ-14,REQ-15,REQ-16,REQ-17,REQ-18,REQ-19,REQ-20,REQ-21,REQ-22,REQ-23,REQ-24,REQ-25,REQ-26,REQ-27,REQ-28,REQ-29,REQ-30,REQ-31,REQ-32,REQ-33,REQ-34,REQ-35,REQ-36,REQ-37,REQ-38]
  partial: []
---/ci---

v1.0 milestone complete: simplified infrastructure-delivery platform
derived from Nova (acdl). 6 phases (P0-P5 + P6 final). 38 REQ-IDs.
38 decisions (D-001..D-038). 76 tests pass. Engine boundary holds.
Happy paths green (check-only + CI). 13 L1 + 2 L2 modules. 5 terraform
roots. Shell reproducibility. Zero OOS files.

Tags: v0.1.0 (P0) → v0.1.1..v0.1.5 (P1..P5) → v0.1.6 (P6 = milestone
release on v0.1 patch line).
2026-08-25 02:18:35 +00:00

60 lines
2.4 KiB
Python

"""Tests for schemas/contract.schema.json — REQ-27.
Validates all 10 sample contracts against the contract schema.
"""
import glob
import jsonschema
import pytest
import yaml
from tests.conftest import ROOT
SAMPLE_CONTRACTS = sorted(glob.glob(str(ROOT / "contracts" / "*.yml")))
class TestSampleContracts:
@pytest.mark.parametrize("path", SAMPLE_CONTRACTS,
ids=[p.split("/")[-1] for p in SAMPLE_CONTRACTS])
def test_validates(self, path, contract_schema):
with open(path) as fh:
contract = yaml.safe_load(fh)
jsonschema.validate(contract, contract_schema)
class TestSchemaNegativeCases:
def _validate(self, instance, schema):
jsonschema.validate(instance, schema)
def test_missing_id_rejected(self, contract_schema):
with pytest.raises(jsonschema.ValidationError):
self._validate({"name": "X", "environment": "dev",
"infrastructure": []}, contract_schema)
def test_bad_id_pattern_rejected(self, contract_schema):
with pytest.raises(jsonschema.ValidationError):
self._validate({"id": "UPPER", "name": "X", "environment": "dev",
"infrastructure": []}, contract_schema)
def test_bad_environment_rejected(self, contract_schema):
with pytest.raises(jsonschema.ValidationError):
self._validate({"id": "abc", "name": "X", "environment": "staging",
"infrastructure": []}, contract_schema)
def test_empty_infrastructure_rejected(self, contract_schema):
with pytest.raises(jsonschema.ValidationError):
self._validate({"id": "abc", "name": "X", "environment": "dev",
"infrastructure": []}, contract_schema)
def test_infrastructure_missing_module_rejected(self, contract_schema):
with pytest.raises(jsonschema.ValidationError):
self._validate({"id": "abc", "name": "X", "environment": "dev",
"infrastructure": [{"inputs": {}}]}, contract_schema)
def test_additional_top_level_rejected(self, contract_schema):
with pytest.raises(jsonschema.ValidationError):
self._validate({"id": "abc", "name": "X", "environment": "dev",
"infrastructure": [{"module": "s3", "inputs": {}}],
"extra": True}, contract_schema)