mekosotto Claude Sonnet 4.6 commited on
Commit
66d1da2
·
1 Parent(s): e3e5c3c

test(agents/routing): regression tests for MRI/EEG/BBB routing heuristic

Browse files

All 5 tests pass on existing code — the bare-directory-without-slash case
already works because Path.exists() resolves relative to cwd, which
monkeypatch.chdir() sets correctly in the test. No routing.py change needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. tests/agents/test_routing.py +44 -0
tests/agents/test_routing.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for src.agents.routing — deterministic workflow-guard fallbacks."""
2
+ from __future__ import annotations
3
+
4
+ from pathlib import Path
5
+
6
+ import pytest
7
+
8
+ from src.agents.routing import route_pipeline_input
9
+
10
+
11
+ class TestRoutePipelineInput:
12
+ def test_smiles_routes_to_bbb(self) -> None:
13
+ assert route_pipeline_input("CCO") == (
14
+ "run_bbb_pipeline",
15
+ {"smiles": "CCO", "top_k": 5},
16
+ )
17
+
18
+ def test_eeg_path_routes_to_eeg(self) -> None:
19
+ name, args = route_pipeline_input("data/raw/sample.fif")
20
+ assert name == "run_eeg_pipeline"
21
+ assert args == {"input_path": "data/raw/sample.fif"}
22
+
23
+ def test_nifti_path_routes_to_mri_with_parent_dir(self) -> None:
24
+ name, args = route_pipeline_input("data/raw/subjects/subject_0.nii.gz")
25
+ assert name == "run_mri_pipeline"
26
+ assert args["input_dir"] == "data/raw/subjects"
27
+
28
+ def test_existing_local_dir_without_slash_routes_to_mri(
29
+ self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
30
+ ) -> None:
31
+ monkeypatch.chdir(tmp_path)
32
+ (tmp_path / "subject_dir").mkdir()
33
+ name, args = route_pipeline_input("subject_dir")
34
+ assert name == "run_mri_pipeline"
35
+ assert args["input_dir"] == "subject_dir"
36
+
37
+ def test_bare_string_with_no_matching_dir_still_routes_to_bbb(
38
+ self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
39
+ ) -> None:
40
+ monkeypatch.chdir(tmp_path)
41
+ # Nothing on disk named "Aspirin" — should be treated as a SMILES-like token
42
+ name, args = route_pipeline_input("Aspirin")
43
+ assert name == "run_bbb_pipeline"
44
+ assert args == {"smiles": "Aspirin", "top_k": 5}