mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-23 03:27:50 +09:00
test: annotate classifier controls and bind canonical resources
This commit is contained in:
2 files changed
+10
-10
No files matched your search
@@ -10,7 +10,7 @@
|
|||||||
"id": "hand-seeded",
|
"id": "hand-seeded",
|
||||||
"source": "manual-curation-pending-regeneration"
|
"source": "manual-curation-pending-regeneration"
|
||||||
},
|
},
|
||||||
"registryDigest": "b21e33d7de6c1f8c1934a7b11d9cb9c5135abb5fd51c7db155eb393cff5fa959",
|
"registryDigest": "c86166ed37f558c3981a97c5f73bb08635b868e2e44e24dae8725f89ed9c3ff3",
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"triggers": {
|
"triggers": {
|
||||||
"skill:agent-runtime-gateway-smoke-test": [
|
"skill:agent-runtime-gateway-smoke-test": [
|
||||||
|
|||||||
@@ -11,36 +11,36 @@ from scripts.parser import ComplianceSpec, Detector, ObservationEvent, Step
|
|||||||
|
|
||||||
|
|
||||||
class TestParseClassification:
|
class TestParseClassification:
|
||||||
def test_plain_json(self):
|
def test_plain_json(self) -> None:
|
||||||
assert _parse_classification('{"a": [0, 2]}') == {"a": [0, 2]}
|
assert _parse_classification('{"a": [0, 2]}') == {"a": [0, 2]}
|
||||||
|
|
||||||
def test_fenced_json(self):
|
def test_fenced_json(self) -> None:
|
||||||
assert _parse_classification('```json\n{"a": [1]}\n```') == {"a": [1]}
|
assert _parse_classification('```json\n{"a": [1]}\n```') == {"a": [1]}
|
||||||
|
|
||||||
def test_dict_without_list_values_is_empty(self):
|
def test_dict_without_list_values_is_empty(self) -> None:
|
||||||
assert _parse_classification('{"a": "x"}') == {}
|
assert _parse_classification('{"a": "x"}') == {}
|
||||||
|
|
||||||
def test_empty_object_is_valid(self):
|
def test_empty_object_is_valid(self) -> None:
|
||||||
assert _parse_classification("{}") == {}
|
assert _parse_classification("{}") == {}
|
||||||
|
|
||||||
def test_garbage_raises(self):
|
def test_garbage_raises(self) -> None:
|
||||||
with pytest.raises(classifier.ClassifierParseError, match="failed to parse"):
|
with pytest.raises(classifier.ClassifierParseError, match="failed to parse"):
|
||||||
_parse_classification("sorry, I cannot classify these")
|
_parse_classification("sorry, I cannot classify these")
|
||||||
|
|
||||||
def test_non_dict_json_raises(self):
|
def test_non_dict_json_raises(self) -> None:
|
||||||
with pytest.raises(classifier.ClassifierParseError, match="non-dict"):
|
with pytest.raises(classifier.ClassifierParseError, match="non-dict"):
|
||||||
_parse_classification("[1, 2, 3]")
|
_parse_classification("[1, 2, 3]")
|
||||||
|
|
||||||
def test_non_integer_indices_raise(self):
|
def test_non_integer_indices_raise(self) -> None:
|
||||||
with pytest.raises(classifier.ClassifierParseError, match="failed to parse"):
|
with pytest.raises(classifier.ClassifierParseError, match="failed to parse"):
|
||||||
_parse_classification('{"a": ["x"]}')
|
_parse_classification('{"a": ["x"]}')
|
||||||
|
|
||||||
def test_is_runtime_error(self):
|
def test_is_runtime_error(self) -> None:
|
||||||
assert issubclass(classifier.ClassifierParseError, RuntimeError)
|
assert issubclass(classifier.ClassifierParseError, RuntimeError)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("response", ["not JSON", "[]", '{"a": ["x"]}'])
|
@pytest.mark.parametrize("response", ["not JSON", "[]", '{"a": ["x"]}'])
|
||||||
def test_grader_propagates_classifier_parse_failure(response):
|
def test_grader_propagates_classifier_parse_failure(response: str) -> None:
|
||||||
"""An invalid successful subprocess response cannot become a zero score."""
|
"""An invalid successful subprocess response cannot become a zero score."""
|
||||||
spec = ComplianceSpec(
|
spec = ComplianceSpec(
|
||||||
id="fixture", name="Fixture", source_rule="fixture", version="1",
|
id="fixture", name="Fixture", source_rule="fixture", version="1",
|
||||||
|
|||||||
Reference in new issue
Block a user