Add unknowns_classifier/tests/test_core.py
This commit is contained in:
parent
cddc8fbaa2
commit
8a9ca02889
1 changed files with 34 additions and 0 deletions
34
unknowns_classifier/tests/test_core.py
Normal file
34
unknowns_classifier/tests/test_core.py
Normal file
|
|
@ -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])
|
||||
Loading…
Reference in a new issue