UnsolvedMedical / tests /test_relations.py
przemekch's picture
Release UnsolvedMed v2.0.0 & v1.5.0 (cleaned <400MB footprint, zero raw excerpts, strict deduplication & sub-domain verification)
ef2c648 verified
Raw History Blame Contribute Delete
949 Bytes
#!/usr/bin/env python3
"""Unit tests for UnsolvedMed relations graph integrity (Section 6.12 & Section 10)."""
import json
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
class TestRelations(unittest.TestCase):
def test_relations_resolve_and_no_self_loops(self):
bundle = json.loads((ROOT / "dataset.json").read_text(encoding="utf-8"))
all_ids = {r["id"] for r in bundle["problems"]}
with (ROOT / "relations" / "relations.jsonl").open("r", encoding="utf-8") as f:
rels = [json.loads(line) for line in f if line.strip()]
self.assertGreaterEqual(len(rels), 5000)
for r in rels:
self.assertIn(r["subject_id"], all_ids)
if r["object_id"].startswith("UMED-"):
self.assertIn(r["object_id"], all_ids)
self.assertNotEqual(r["subject_id"], r["object_id"])
if __name__ == "__main__":
unittest.main()