generated from coulomb/repo-seed
Implement infospace scaffold and service baseline
This commit is contained in:
26
tests/test_api.py
Normal file
26
tests/test_api.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from http import HTTPStatus
|
||||
|
||||
from info_tech_canon.api import _route
|
||||
|
||||
|
||||
def test_api_route_inspect() -> None:
|
||||
status, payload = _route("/inspect", {}, None)
|
||||
|
||||
assert status == HTTPStatus.OK
|
||||
assert payload["ok"] is True
|
||||
assert payload["infospace"]["slug"] == "canon"
|
||||
|
||||
|
||||
def test_api_route_validate() -> None:
|
||||
status, payload = _route("/validate", {}, None)
|
||||
|
||||
assert status == HTTPStatus.OK
|
||||
assert payload["ok"] is True
|
||||
|
||||
|
||||
def test_api_route_unknown_endpoint() -> None:
|
||||
status, payload = _route("/missing", {}, None)
|
||||
|
||||
assert status == HTTPStatus.NOT_FOUND
|
||||
assert payload["ok"] is False
|
||||
assert payload["error"]["code"] == "not_found"
|
||||
21
tests/test_cli.py
Normal file
21
tests/test_cli.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import json
|
||||
|
||||
from info_tech_canon.cli import main
|
||||
|
||||
|
||||
def test_cli_inspect_emits_json(capsys) -> None:
|
||||
exit_code = main(["inspect"])
|
||||
|
||||
assert exit_code == 0
|
||||
payload = json.loads(capsys.readouterr().out)
|
||||
assert payload["ok"] is True
|
||||
assert payload["infospace"]["artifact_count"] == 15
|
||||
|
||||
|
||||
def test_cli_missing_profile_uses_structured_error(capsys) -> None:
|
||||
exit_code = main(["profile", "inspect", "small-saas"])
|
||||
|
||||
assert exit_code == 2
|
||||
payload = json.loads(capsys.readouterr().out)
|
||||
assert payload["ok"] is False
|
||||
assert payload["error"]["code"] == "missing_profile"
|
||||
41
tests/test_service.py
Normal file
41
tests/test_service.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from info_tech_canon.service import (
|
||||
artifact_graph,
|
||||
inspect_canon,
|
||||
list_models,
|
||||
list_standards,
|
||||
validate_canon,
|
||||
)
|
||||
|
||||
|
||||
def test_inspect_canon_counts_artifact_kinds() -> None:
|
||||
payload = inspect_canon()
|
||||
|
||||
assert payload["ok"] is True
|
||||
assert payload["infospace"]["slug"] == "canon"
|
||||
assert payload["infospace"]["artifact_count"] == 15
|
||||
assert payload["infospace"]["kinds"] == {
|
||||
"kernel": 2,
|
||||
"model": 11,
|
||||
"standard": 2,
|
||||
}
|
||||
|
||||
|
||||
def test_model_and_standard_lists_are_filtered() -> None:
|
||||
assert list_models()["count"] == 11
|
||||
assert list_standards()["count"] == 2
|
||||
|
||||
|
||||
def test_validate_canon_passes_scaffold() -> None:
|
||||
payload = validate_canon()
|
||||
|
||||
assert payload["ok"] is True
|
||||
assert payload["errors"] == []
|
||||
assert payload["details"]["artifact_count"] == 15
|
||||
|
||||
|
||||
def test_graph_exports_relationship_summary() -> None:
|
||||
payload = artifact_graph()
|
||||
|
||||
assert payload["ok"] is True
|
||||
assert payload["graph"]["node_count"] == 15
|
||||
assert payload["graph"]["edge_count"] > 15
|
||||
Reference in New Issue
Block a user