Download tests/test_topology.py from tailot/lingologos-thinkingpython: direct link, hf CLI and curl.
- Browser
- Download file 2.59 kB
-
https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/tests/test_topology.py
- Command line
-
hf download hf://datasets/tailot/lingologos-thinkingpython/tests/test_topology.py
-
curl -L -o test_topology.py https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/tests/test_topology.py
2.59 kB
| """Seven nodes, each with a budget, two of them independent.""" | |
| import json | |
| import os | |
| import sys | |
| import unittest | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| sys.path.insert(0, ROOT) | |
| from nodes import arbiter # noqa: E402 | |
| EXPECTED = ["intent", "locator", "planner", "executor", "gate_checker", "adversary", | |
| "arbiter"] | |
| class Topology(unittest.TestCase): | |
| def setUp(self): | |
| with open(os.path.join(ROOT, "topology.json"), "r", encoding="utf-8") as handle: | |
| self.config = json.load(handle) | |
| self.nodes = self.config["nodes"] | |
| def test_seven_nodes_in_order(self): | |
| self.assertEqual([n["name"] for n in self.nodes], EXPECTED) | |
| def test_every_node_has_a_budget_and_a_script(self): | |
| for node in self.nodes: | |
| self.assertTrue(os.path.isfile(os.path.join(ROOT, node["script"])), node["name"]) | |
| self.assertGreater(float(node["budget"]), 0.0, node["name"]) | |
| def test_only_intent_is_non_deterministic(self): | |
| free = [n["name"] for n in self.nodes if not n.get("deterministic", True)] | |
| self.assertEqual(free, ["intent"]) | |
| def test_two_independent_checkers(self): | |
| independent = [n["name"] for n in self.nodes if n.get("independent")] | |
| self.assertEqual(independent, ["gate_checker", "adversary"]) | |
| def test_assurance_three_needs_both(self): | |
| base = [{"node": "intent", "status": "ok"}, {"node": "locator", "status": "ok"}, | |
| {"node": "planner", "status": "ok"}, {"node": "executor", "status": "ok"}] | |
| both = arbiter.combine(base + [{"node": "gate_checker", "status": "pass"}, | |
| {"node": "adversary", "status": "survived"}]) | |
| one = arbiter.combine(base + [{"node": "gate_checker", "status": "pass"}, | |
| {"node": "adversary", "status": "refuted"}]) | |
| none = arbiter.combine(base + [{"node": "gate_checker", "status": "fail"}, | |
| {"node": "adversary", "status": "refuted"}]) | |
| self.assertEqual((both[0], both[1]), ("VERIFIED", 3)) | |
| self.assertEqual((one[0], one[1]), ("SINGLE_PROVER", 2)) | |
| self.assertEqual(none[0], "REFUSED") | |
| def test_refusal_before_execution_never_reaches_three(self): | |
| verdict, assurance, _ = arbiter.combine( | |
| [{"node": "intent", "status": "ok"}, | |
| {"node": "locator", "status": "refused", "reasons": ["NO_TEST_FILE"]}]) | |
| self.assertEqual((verdict, assurance), ("REFUSED", 0)) | |
| if __name__ == "__main__": | |
| unittest.main() | |