Skip to content

Commit

Permalink
✅ (test_schema.py): add additional test cases for post_process_type f…
Browse files Browse the repository at this point in the history
…unction to cover various Union types and combinations for better test coverage and accuracy
  • Loading branch information
Cristhianzl committed Oct 14, 2024
1 parent 0b36833 commit 1772260
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/backend/tests/unit/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,25 @@ def test_post_process_type_function(self):
assert set(post_process_type(dict)) == {dict}
assert set(post_process_type(tuple)) == {tuple}

# Union with custom types
assert set(post_process_type(Union[Data, str])) == {Data, str}
assert set(post_process_type(Data | str)) == {Data, str}
assert set(post_process_type(Data | int | list[str])) == {Data, int, str}

# More complex combinations with Data
assert set(post_process_type(Data | list[float])) == {Data, float}
assert set(post_process_type(Data | Union[int, str])) == {Data, int, str}
assert set(post_process_type(Data | list[int] | None)) == {Data, int, type(None)}
assert set(post_process_type(Data | Union[float, None])) == {Data, float, type(None)}

# Multiple Data types combined
assert set(post_process_type(Union[Data, Union[str, float]])) == {Data, str, float}
assert set(post_process_type(Union[Data | float | str, int])) == {Data, int, float, str}

# Testing with nested unions and lists
assert set(post_process_type(Union[list[Data], list[Union[int, str]]])) == {Data, int, str}
assert set(post_process_type(Data | list[Union[float, str]])) == {Data, float, str}

def test_input_to_dict(self):
input_obj = Input(field_type="str")
assert input_obj.to_dict() == {
Expand Down

0 comments on commit 1772260

Please sign in to comment.