|
| 1 | +import pytest |
| 2 | +from t4_devkit.schema.tables.autolabel_metadata import AutolabelModel, AutolabelMixin |
| 3 | + |
| 4 | + |
| 5 | +class TestAutolabelModel: |
| 6 | + """Test cases for AutolabelModel class that are not covered elsewhere.""" |
| 7 | + |
| 8 | + def test_to_autolabel_model_type_error(self): |
| 9 | + """Test to_autolabel_model raises TypeError for invalid input.""" |
| 10 | + with pytest.raises(TypeError, match="Input must be None or a list of \\[dicts or AutolabelModel\\] instances."): |
| 11 | + AutolabelModel.to_autolabel_model("invalid_input") |
| 12 | + |
| 13 | + def test_to_autolabel_model_type_error_with_dict(self): |
| 14 | + """Test to_autolabel_model raises TypeError when input is a dict instead of list.""" |
| 15 | + with pytest.raises(TypeError, match="Input must be None or a list of \\[dicts or AutolabelModel\\] instances."): |
| 16 | + AutolabelModel.to_autolabel_model({"name": "model1", "score": 0.8}) |
| 17 | + |
| 18 | + def test_to_autolabel_model_type_error_with_number(self): |
| 19 | + """Test to_autolabel_model raises TypeError when input is a number.""" |
| 20 | + with pytest.raises(TypeError, match="Input must be None or a list of \\[dicts or AutolabelModel\\] instances."): |
| 21 | + AutolabelModel.to_autolabel_model(123) |
| 22 | + |
| 23 | + |
| 24 | +class TestAutolabelMixin: |
| 25 | + """Test cases for AutolabelMixin class that are not covered elsewhere.""" |
| 26 | + |
| 27 | + def test_autolabel_mixin_error_automatic_true_no_metadata(self): |
| 28 | + """Test AutolabelMixin raises TypeError when automatic_annotation=True but autolabel_metadata=None.""" |
| 29 | + with pytest.raises(TypeError, match="autolabel_metadata must be provided when automatic_annotation is True"): |
| 30 | + AutolabelMixin(automatic_annotation=True, autolabel_metadata=None) |
| 31 | + |
| 32 | + def test_autolabel_mixin_error_automatic_false_with_metadata(self): |
| 33 | + """Test AutolabelMixin raises TypeError when automatic_annotation=False but autolabel_metadata is provided.""" |
| 34 | + models = [AutolabelModel(name="test_model", score=0.8)] |
| 35 | + with pytest.raises(TypeError, match="autolabel_metadata must be None when automatic_annotation is False"): |
| 36 | + AutolabelMixin(automatic_annotation=False, autolabel_metadata=models) |
| 37 | + |
| 38 | + def test_autolabel_mixin_error_default_automatic_with_metadata(self): |
| 39 | + """Test AutolabelMixin raises TypeError when default automatic_annotation=False but autolabel_metadata is provided.""" |
| 40 | + models = [AutolabelModel(name="test_model", score=0.8)] |
| 41 | + with pytest.raises(TypeError, match="autolabel_metadata must be None when automatic_annotation is False"): |
| 42 | + AutolabelMixin(autolabel_metadata=models) |
0 commit comments