Files
frame/tests/test_evidence.py
T
lainandSisyphus a6d6168fd5 chore: add community files, CI workflows, and host test tooling
Add the repository-facing scaffolding:

- Community/legal: README.md, LICENSE (GPL-3.0-or-later), NOTICE,
  CONTRIBUTING.md, SECURITY.md, CODE_OF_CONDUCT.md, .gitleaks.toml
- CI: .github/ workflows (ci.yml aggregate gate, nightly.yml, codeql.yml),
  issue/PR templates, dependabot config (pinned Actions per README)
- Host tooling: tools/frame_tools (ruff/pyright/pytest gates, partition,
  evidence-schema, doc-links, SBOM checks), tests/, pyproject.toml, uv.lock
- poc/ host side: poc/host contract-test suite (ASan/TSan-capable),
  poc/README.md, poc/poc-a.code-workspace

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
2026-08-31 08:00:51 +08:00

77 lines
2.1 KiB
Python

import json
from pathlib import Path
from frame_tools.evidence import discover_manifests, validate_evidence
SCHEMA = Path("poc/evidence/schema.json")
def valid_manifest() -> dict[str, object]:
return {
"schema_version": 1,
"gate": "A",
"run_id": "test-run",
"verdict": "BLOCKED",
"started_at": "2026-08-30T00:00:00Z",
"finished_at": "2026-08-30T00:01:00Z",
"source": {
"repository_commit": "0" * 40,
"dirty": False,
"project_document_sha256": "0" * 64,
},
"platform": {
"idf_tag": "v6.0.2",
"compiler": "test compiler",
"target": "esp32s3",
"sdkconfig_sha256": "0" * 64,
},
"artifacts": [{"name": "log", "uri": "log.txt", "sha256": "0" * 64}],
}
def test_valid_manifest_passes(tmp_path: Path) -> None:
path = tmp_path / "manifest.json"
path.write_text(json.dumps(valid_manifest()), encoding="utf-8")
assert validate_evidence(SCHEMA, [path]) == []
def test_m1_gate_manifest_passes(tmp_path: Path) -> None:
manifest = valid_manifest()
manifest["gate"] = "M1"
path = tmp_path / "manifest.json"
path.write_text(json.dumps(manifest), encoding="utf-8")
assert validate_evidence(SCHEMA, [path]) == []
def test_invalid_manifest_reports_json_path(tmp_path: Path) -> None:
manifest = valid_manifest()
manifest["gate"] = "F"
path = tmp_path / "manifest.json"
path.write_text(json.dumps(manifest), encoding="utf-8")
errors = validate_evidence(SCHEMA, [path])
assert errors
assert "['gate']" in errors[0]
def test_invalid_date_time_is_rejected(tmp_path: Path) -> None:
manifest = valid_manifest()
manifest["started_at"] = "not-a-date"
path = tmp_path / "manifest.json"
path.write_text(json.dumps(manifest), encoding="utf-8")
errors = validate_evidence(SCHEMA, [path])
assert errors
assert "['started_at']" in errors[0]
def test_schema_is_not_discovered_as_a_manifest() -> None:
manifests, errors = discover_manifests([SCHEMA.parent], SCHEMA)
assert errors == []
assert SCHEMA not in manifests