Skip to content

Commit

Permalink
Add a test to check the error when you pass an unrecognized transform…
Browse files Browse the repository at this point in the history
… type to apply_transform()
  • Loading branch information
riley-harper committed Aug 26, 2024
1 parent 8e3ddb8 commit 1b768a0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hlink/tests/core/transforms_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ def test_generate_transforms_error_when_unrecognized_transform(

@pytest.mark.parametrize("is_a", [True, False])
def test_apply_transform_when_value(spark: SparkSession, is_a: bool) -> None:
"""The when_value transform supports simple if-then-otherwise logic on
columns:
if the column is equal to "when_value"
then return "if_value"
otherwise return "else_value"
"""
transform = {"type": "when_value", "value": 6, "if_value": 0, "else_value": 1}
column_select = col("marst")
output_col = apply_transform(column_select, transform, is_a)
Expand All @@ -225,3 +232,11 @@ def test_apply_transform_when_value(spark: SparkSession, is_a: bool) -> None:
Row(marst=6, output=0),
Row(marst=1, output=1),
]


@pytest.mark.parametrize("is_a", [True, False])
def test_apply_transform_error_when_unrecognized_transform_type(is_a: bool) -> None:
column_select = col("test")
transform = {"type": "not_supported"}
with pytest.raises(ValueError, match="Invalid transform type"):
apply_transform(column_select, transform, is_a)

0 comments on commit 1b768a0

Please sign in to comment.