Skip to content

Commit 55544ce

Browse files
committed
Split symmetry test into documents and probes for easier debugging
Separates test_build_session_artifacts into two independent tests: - test_build_session_documents: verifies JSON document round-trip (runs first) - test_build_session_probes: verifies probe reconstruction (depends on more) This makes it easier to isolate failures since getprobes depends on many other things working correctly. https://claude.ai/code/session_01RBSaNF8SSrGqnpnP5vUT47
1 parent 3ea3a99 commit 55544ce

1 file changed

Lines changed: 44 additions & 44 deletions

File tree

tests/symmetry/read_artifacts/session/test_build_session.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
``makeArtifacts`` suite and verifies that the Python NDI stack can:
88
99
1. Open the copied session database.
10-
2. Reconstruct probes that match ``probes.json``.
11-
3. Load every document whose JSON was exported to ``jsonDocuments/``.
10+
2. Load every document whose JSON was exported to ``jsonDocuments/``.
11+
3. Reconstruct probes that match ``probes.json``.
1212
1313
The test is parameterized over ``source_type`` so that a single test class
1414
covers both ``matlabArtifacts`` and ``pythonArtifacts``.
@@ -37,57 +37,21 @@ def _artifact_dir(self, source_type: str):
3737
SYMMETRY_BASE / source_type / "session" / "buildSession" / "testBuildSessionArtifacts"
3838
)
3939

40-
# -- tests ---------------------------------------------------------------
41-
42-
def test_build_session_artifacts(self, source_type):
43-
"""Verify session artifacts from the given source."""
40+
def _open_session(self, source_type):
4441
artifact_dir = self._artifact_dir(source_type)
45-
4642
if not artifact_dir.exists():
4743
pytest.skip(
4844
f"Artifact directory from {source_type} does not exist. "
4945
f"Run the corresponding makeArtifacts suite first."
5046
)
47+
return artifact_dir, DirSession("exp1", artifact_dir)
5148

52-
# 1. Open the NDI session -------------------------------------------
53-
session = DirSession("exp1", artifact_dir)
49+
# -- tests (documents first, then probes) --------------------------------
5450

55-
# 2. Verify probes --------------------------------------------------
56-
probes_json_path = artifact_dir / "probes.json"
57-
if not probes_json_path.exists():
58-
pytest.skip(f"probes.json not found in {source_type} artifact directory.")
51+
def test_build_session_documents(self, source_type):
52+
"""Verify that every exported JSON document can be loaded from the session DB."""
53+
artifact_dir, session = self._open_session(source_type)
5954

60-
expected_probes = json.loads(probes_json_path.read_text(encoding="utf-8"))
61-
actual_probes = session.getprobes()
62-
63-
assert len(actual_probes) == len(expected_probes), (
64-
f"Number of actual probes ({len(actual_probes)}) does not match "
65-
f"{source_type} generated artifacts ({len(expected_probes)})."
66-
)
67-
68-
# Match probes by (name, reference, type)
69-
if len(actual_probes) == len(expected_probes):
70-
for expected in expected_probes:
71-
found = False
72-
for actual in actual_probes:
73-
if (
74-
actual.name == expected["name"]
75-
and actual.reference == expected["reference"]
76-
and actual.type == expected["type"]
77-
):
78-
found = True
79-
assert getattr(actual, "subject_id", "") == expected.get(
80-
"subject_id", ""
81-
), (
82-
f"Subject ID mismatch for probe {expected['name']} " f"in {source_type}"
83-
)
84-
break
85-
assert found, (
86-
f"Probe from {source_type} artifact not found in session: "
87-
f"{expected['name']}"
88-
)
89-
90-
# 3. Verify documents -----------------------------------------------
9155
json_docs_dir = artifact_dir / "jsonDocuments"
9256
if not json_docs_dir.exists():
9357
pytest.skip(f"jsonDocuments directory not found in {source_type}.")
@@ -119,3 +83,39 @@ def test_build_session_artifacts(self, source_type):
11983
assert found, (
12084
f"Document from {source_type} artifact not found in session: " f"{expected_id}"
12185
)
86+
87+
def test_build_session_probes(self, source_type):
88+
"""Verify that probes reconstructed from the session match probes.json."""
89+
artifact_dir, session = self._open_session(source_type)
90+
91+
probes_json_path = artifact_dir / "probes.json"
92+
if not probes_json_path.exists():
93+
pytest.skip(f"probes.json not found in {source_type} artifact directory.")
94+
95+
expected_probes = json.loads(probes_json_path.read_text(encoding="utf-8"))
96+
actual_probes = session.getprobes()
97+
98+
assert len(actual_probes) == len(expected_probes), (
99+
f"Number of actual probes ({len(actual_probes)}) does not match "
100+
f"{source_type} generated artifacts ({len(expected_probes)})."
101+
)
102+
103+
for expected in expected_probes:
104+
found = False
105+
for actual in actual_probes:
106+
if (
107+
actual.name == expected["name"]
108+
and actual.reference == expected["reference"]
109+
and actual.type == expected["type"]
110+
):
111+
found = True
112+
assert getattr(actual, "subject_id", "") == expected.get(
113+
"subject_id", ""
114+
), (
115+
f"Subject ID mismatch for probe {expected['name']} " f"in {source_type}"
116+
)
117+
break
118+
assert found, (
119+
f"Probe from {source_type} artifact not found in session: "
120+
f"{expected['name']}"
121+
)

0 commit comments

Comments
 (0)