Skip to content

Commit

Permalink
test: add missing test for de-serializing complex types
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Jan 10, 2025
1 parent a32ac76 commit 2980a93
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions openedx_events/event_bus/avro/tests/test_deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,20 @@ def test_deserialization_of_dict_without_annotation(self):
with self.assertRaises(TypeError):
deserializer.from_dict(initial_dict)

def test_deserialization_of_dict_with_complex_types_fails(self):
SIGNAL = create_simple_signal({"dict_input": Dict[str, list]})
with self.assertRaises(TypeError):
AvroSignalDeserializer(SIGNAL)
initial_dict = {"dict_input": {"key1": [1, 3], "key2": [4, 5]}}
# create dummy signal to bypass schema check while initializing deserializer
# This allows us to test whether correct exceptions are raised while deserializing data
DUMMY_SIGNAL = create_simple_signal({"dict_input": Dict[str, int]})
deserializer = AvroSignalDeserializer(DUMMY_SIGNAL)
# Update signal with incorrect type info
deserializer.signal = SIGNAL
with self.assertRaises(TypeError):
deserializer.from_dict(initial_dict)

def test_deserialization_of_nested_list_fails(self):
"""
Check that deserialization raises error when nested list data is passed.
Expand Down

0 comments on commit 2980a93

Please sign in to comment.