tenseleyflow/sway / 59b0e7c

Browse files

tests/probe_base: cover validate_all_probes — multi-error collection + index-label fallback (B7)

Authored by espadonne
SHA
59b0e7cc1bad1c28e95c60b03e497a591a46ebed
Parents
c29261f
Tree
cd7950a

1 changed file

StatusFile+-
M tests/unit/test_probe_base.py 40 1
tests/unit/test_probe_base.pymodified
@@ -8,7 +8,14 @@ import pytest
88
 
99
 from dlm_sway.core.errors import SpecValidationError
1010
 from dlm_sway.core.result import ProbeResult, Verdict
11
-from dlm_sway.probes.base import Probe, ProbeSpec, RunContext, build_probe, registry
11
+from dlm_sway.probes.base import (
12
+    Probe,
13
+    ProbeSpec,
14
+    RunContext,
15
+    build_probe,
16
+    registry,
17
+    validate_all_probes,
18
+)
1219
 
1320
 
1421
 class _DummySpec(ProbeSpec):
@@ -67,3 +74,35 @@ class TestBuildProbe:
6774
         with pytest.raises(SpecValidationError) as exc_info:
6875
             build_probe({"name": "t", "kind": "__test_dummy", "bogus": "y"})
6976
         assert "bogus" in str(exc_info.value).lower()
77
+
78
+
79
+class TestValidateAllProbes:
80
+    """B7: collect every probe-entry error in a single message."""
81
+
82
+    def test_clean_suite_passes(self) -> None:
83
+        validate_all_probes(
84
+            [
85
+                {"name": "p1", "kind": "__test_dummy"},
86
+                {"name": "p2", "kind": "__test_dummy", "payload": "y"},
87
+            ]
88
+        )
89
+
90
+    def test_collects_multiple_errors(self) -> None:
91
+        with pytest.raises(SpecValidationError) as exc_info:
92
+            validate_all_probes(
93
+                [
94
+                    {"name": "good", "kind": "__test_dummy"},
95
+                    {"name": "typo1", "kind": "no_such_kind"},
96
+                    {"name": "typo2", "kind": "another_typo"},
97
+                ]
98
+            )
99
+        msg = str(exc_info.value)
100
+        # Both typos surface in one message — the user fixes everything in one pass.
101
+        assert "typo1" in msg
102
+        assert "typo2" in msg
103
+        assert "no_such_kind" in msg
104
+        assert "another_typo" in msg
105
+
106
+    def test_unnamed_entry_uses_index_label(self) -> None:
107
+        with pytest.raises(SpecValidationError, match="entry #0"):
108
+            validate_all_probes([{"kind": "no_such_kind"}])