feat(fifth-domain): add whole language system runtime
This commit is contained in:
parent
beb7fbd805
commit
e3e494338a
20 changed files with 1340 additions and 3 deletions
|
|
@ -0,0 +1,65 @@
|
|||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SPEC = importlib.util.spec_from_file_location("language_system", ROOT / "scripts/language_system.py")
|
||||
MODULE = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(MODULE)
|
||||
PUBLIC_SPEC = importlib.util.spec_from_file_location("public_language_system", ROOT / "scripts/public_language_system.py")
|
||||
PUBLIC_MODULE = importlib.util.module_from_spec(PUBLIC_SPEC)
|
||||
PUBLIC_SPEC.loader.exec_module(PUBLIC_MODULE)
|
||||
|
||||
|
||||
class LanguageSystemTests(unittest.TestCase):
|
||||
def test_private_and_public_materialize_and_verify(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
base = Path(directory)
|
||||
private = base / "private"
|
||||
public = base / "public"
|
||||
MODULE.build(ROOT / "system/fifth-domain-system.json", private, "fifth-domain")
|
||||
MODULE.build(ROOT / "system/public-four-domain-template.json", public, "public-four-domain")
|
||||
self.assertEqual(MODULE.verify(private)["outcome"], "PASS")
|
||||
self.assertEqual(MODULE.verify(public)["outcome"], "PASS")
|
||||
self.assertEqual(len(list(public.glob("*/NODE.json"))), 4)
|
||||
|
||||
def test_public_private_marker_rejected(self):
|
||||
value = MODULE.load_json(ROOT / "system/public-four-domain-template.json")
|
||||
value["responsible_human"] = "ICE-GL∞"
|
||||
with self.assertRaisesRegex(ValueError, "private markers leaked"):
|
||||
MODULE.validate_public(value)
|
||||
|
||||
def test_standalone_public_materializer(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory) / "public"
|
||||
PUBLIC_MODULE.build(ROOT / "system/public-four-domain-template.json", output)
|
||||
self.assertEqual(PUBLIC_MODULE.verify(output)["outcome"], "PASS")
|
||||
value = MODULE.load_json(ROOT / "system/public-four-domain-template.json")
|
||||
value["responsible_human"] = "ICE-PRIVATE"
|
||||
with self.assertRaisesRegex(ValueError, "unbound|private"):
|
||||
PUBLIC_MODULE.validate(value)
|
||||
|
||||
def test_tamper_rejected(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory) / "private"
|
||||
MODULE.build(ROOT / "system/fifth-domain-system.json", output, "fifth-domain")
|
||||
world = json.loads((output / "WORLD.json").read_text())
|
||||
world["flavor"] = "tampered"
|
||||
(output / "WORLD.json").write_text(json.dumps(world))
|
||||
with self.assertRaisesRegex(ValueError, "mismatch"):
|
||||
MODULE.verify(output)
|
||||
|
||||
def test_meta_audit(self):
|
||||
result = MODULE.meta_audit(
|
||||
ROOT / "system/fifth-domain-system.json",
|
||||
ROOT / "system/public-four-domain-template.json",
|
||||
ROOT / "system/legacy-route-map.json",
|
||||
)
|
||||
self.assertEqual(result["outcome"], "PASS")
|
||||
self.assertEqual(result["yaoming_current_id"], "ICE-BB-0001")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Reference in a new issue