2443909362
---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).
70 lines
2.7 KiB
Python
70 lines
2.7 KiB
Python
"""Tests for schemas/stack.schema.json — REQ-28.
|
|
|
|
Validates resolved stacks against the stack schema. Builds stacks via
|
|
resolve() using a registry fixture.
|
|
"""
|
|
|
|
import jsonschema
|
|
import pytest
|
|
|
|
from core.contract_resolver import resolve
|
|
|
|
|
|
def _contract():
|
|
return {
|
|
"id": "stsi",
|
|
"name": "Test",
|
|
"environment": "dev",
|
|
"infrastructure": [
|
|
{"module": "static-assets", "version": "1.0.0",
|
|
"inputs": {"bucket_name": "test-bucket", "index_document": "index.html"}},
|
|
],
|
|
}
|
|
|
|
|
|
class TestStackSchema:
|
|
def test_resolved_stack_validates(self, registry, repo_root, stack_schema):
|
|
stack = resolve(_contract(), registry, repo_root / "modules",
|
|
repo_root=repo_root)
|
|
jsonschema.validate(stack, stack_schema)
|
|
|
|
def test_multi_resource_stack_validates(self, registry, repo_root, stack_schema):
|
|
contract = {
|
|
"id": "stsi", "name": "Test", "environment": "dev",
|
|
"infrastructure": [
|
|
{"module": "static-assets", "version": "1.0.0",
|
|
"inputs": {"bucket_name": "b1", "index_document": "index.html"}},
|
|
{"module": "microservice", "version": "1.0.0",
|
|
"inputs": {"service_name": "s1", "desired_count": 2}},
|
|
],
|
|
}
|
|
stack = resolve(contract, registry, repo_root / "modules",
|
|
repo_root=repo_root)
|
|
assert len(stack["resources"]) == 2
|
|
jsonschema.validate(stack, stack_schema)
|
|
|
|
|
|
class TestStackSchemaNegative:
|
|
def test_missing_resources_rejected(self, stack_schema):
|
|
bad = {"contract_id": "x", "contract_name": "X", "environment": "dev"}
|
|
with pytest.raises(jsonschema.ValidationError):
|
|
jsonschema.validate(bad, stack_schema)
|
|
|
|
def test_empty_resources_rejected(self, stack_schema):
|
|
bad = {"contract_id": "x", "contract_name": "X", "environment": "dev",
|
|
"resources": []}
|
|
with pytest.raises(jsonschema.ValidationError):
|
|
jsonschema.validate(bad, stack_schema)
|
|
|
|
def test_resource_missing_module_rejected(self, stack_schema):
|
|
bad = {"contract_id": "x", "contract_name": "X", "environment": "dev",
|
|
"resources": [{"version": "1.0.0", "inputs": {}}]}
|
|
with pytest.raises(jsonschema.ValidationError):
|
|
jsonschema.validate(bad, stack_schema)
|
|
|
|
def test_resource_extra_source_rejected(self, stack_schema):
|
|
bad = {"contract_id": "x", "contract_name": "X", "environment": "dev",
|
|
"resources": [{"module": "s3", "version": "1.0.0", "inputs": {},
|
|
"source": "modules/l1/s3/terraform"}]}
|
|
with pytest.raises(jsonschema.ValidationError):
|
|
jsonschema.validate(bad, stack_schema) |