mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-26 18:35:05 +00:00
test: annotate classifier controls and bind canonical resources
This commit is contained in:
2 files changed
+10
-10
No files matched your search
@@ -11,36 +11,36 @@ from scripts.parser import ComplianceSpec, Detector, ObservationEvent, Step
|
||||
|
||||
|
||||
class TestParseClassification:
|
||||
def test_plain_json(self):
|
||||
def test_plain_json(self) -> None:
|
||||
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]}
|
||||
|
||||
def test_dict_without_list_values_is_empty(self):
|
||||
def test_dict_without_list_values_is_empty(self) -> None:
|
||||
assert _parse_classification('{"a": "x"}') == {}
|
||||
|
||||
def test_empty_object_is_valid(self):
|
||||
def test_empty_object_is_valid(self) -> None:
|
||||
assert _parse_classification("{}") == {}
|
||||
|
||||
def test_garbage_raises(self):
|
||||
def test_garbage_raises(self) -> None:
|
||||
with pytest.raises(classifier.ClassifierParseError, match="failed to parse"):
|
||||
_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"):
|
||||
_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"):
|
||||
_parse_classification('{"a": ["x"]}')
|
||||
|
||||
def test_is_runtime_error(self):
|
||||
def test_is_runtime_error(self) -> None:
|
||||
assert issubclass(classifier.ClassifierParseError, RuntimeError)
|
||||
|
||||
|
||||
@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."""
|
||||
spec = ComplianceSpec(
|
||||
id="fixture", name="Fixture", source_rule="fixture", version="1",
|
||||
|
||||
Reference in new issue
Block a user