diff --git a/unknowns_classifier/tests/test_core.py b/unknowns_classifier/tests/test_core.py new file mode 100644 index 0000000..2696958 --- /dev/null +++ b/unknowns_classifier/tests/test_core.py @@ -0,0 +1,34 @@ +import pytest +from unknowns_classifier import core + +@pytest.fixture +def sample_unknowns(): + return [ + {"message": "Schema mismatch detected in run A"}, + {"message": "Missing artifact: model.pkl"}, + {"message": "Schema mismatch in run B"}, + {"message": "Unknown artifact missing: data.csv"}, + ] + +def test_classify_unknowns_nominal(sample_unknowns): + results = core.classify_unknowns(sample_unknowns) + assert isinstance(results, list) + assert all(isinstance(r, core.UnknownClassification) for r in results) + + types = [r.unknown_type for r in results] + counts = {r.unknown_type: r.count for r in results} + + assert "schema_mismatch" in types + assert "artefakt_fehlt" in types + + assert counts["schema_mismatch"] == 2 + assert counts["artefakt_fehlt"] == 2 + +def test_classify_unknowns_empty(): + results = core.classify_unknowns([]) + assert isinstance(results, list) + assert len(results) == 0 + +def test_classify_unknowns_invalid_input(): + with pytest.raises((TypeError, KeyError)): + core.classify_unknowns(["not_a_dict", None, 123])