Skip to content

Commit

Permalink
refactor: address PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Dec 16, 2024
1 parent acdcaa9 commit 00fd4ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion openedx_events/event_bus/avro/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def _event_data_to_avro_record_dict(event_data, serializers=None):
def value_to_dict(value):
# Case 1: Value is an instance of an attrs-decorated class
if hasattr(value, "__attrs_attrs__"):
print("\n\n MY VALUE IN VALUE TO DICT", value, "\n\n")
return attr.asdict(value, value_serializer=_get_non_attrs_serializer(serializers))
return _get_non_attrs_serializer(serializers)(None, None, value)

Expand Down
8 changes: 6 additions & 2 deletions openedx_events/event_bus/avro/tests/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Tests for event_bus.avro.schema module
"""
from typing import List
from typing import List, Dict
from unittest import TestCase

from openedx_events.event_bus.avro.schema import schema_from_signal
Expand Down Expand Up @@ -245,8 +245,9 @@ class UnextendedClass:

def test_throw_exception_to_list_or_dict_types_without_annotation(self):
LIST_SIGNAL = create_simple_signal({"list_input": list})
DICT_SIGNAL = create_simple_signal({"list_input": dict})
DICT_SIGNAL = create_simple_signal({"dict_input": dict})
LIST_WITHOUT_ANNOTATION_SIGNAL = create_simple_signal({"list_input": List})
DICT_WITHOUT_ANNOTATION_SIGNAL = create_simple_signal({"dict_input": Dict})
with self.assertRaises(Exception):
schema_from_signal(LIST_SIGNAL)

Expand All @@ -256,6 +257,9 @@ def test_throw_exception_to_list_or_dict_types_without_annotation(self):
with self.assertRaises(TypeError):
schema_from_signal(LIST_WITHOUT_ANNOTATION_SIGNAL)

with self.assertRaises(TypeError):
schema_from_signal(DICT_WITHOUT_ANNOTATION_SIGNAL)

def test_list_with_annotation_works(self):
LIST_SIGNAL = create_simple_signal({"list_input": List[int]})
expected_dict = {
Expand Down

0 comments on commit 00fd4ac

Please sign in to comment.