Skip to content

Commit

Permalink
Add test for ValueNotPresentWhenFittedError
Browse files Browse the repository at this point in the history
  • Loading branch information
zzril committed May 9, 2023
1 parent 9923aa6 commit f2e347d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/safeds/data/tabular/transformation/test_one_hot_encoder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from safeds.data.tabular.containers import Table
from safeds.data.tabular.transformation import OneHotEncoder
from safeds.exceptions import TransformerNotFittedError, UnknownColumnNameError
from safeds.exceptions import TransformerNotFittedError, UnknownColumnNameError, ValueNotPresentWhenFittedError


class TestFit:
Expand Down Expand Up @@ -60,6 +60,23 @@ def test_should_raise_if_not_fitted(self) -> None:
with pytest.raises(TransformerNotFittedError):
transformer.transform(table)

def test_should_raise_value_not_present_when_fitted(self) -> None:
fit_table = Table(
{
"col1": ["a"],
},
)
transform_table = Table(
{
"col1": ["b"],
},
)

transformer = OneHotEncoder().fit(fit_table, None)

with pytest.raises(ValueNotPresentWhenFittedError):
transformer.transform(transform_table)


class TestIsFitted:
def test_should_return_false_before_fitting(self) -> None:
Expand Down

0 comments on commit f2e347d

Please sign in to comment.