Skip to content

Commit

Permalink
fixup!: changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Graber committed Aug 8, 2023
1 parent 6de632f commit 663281e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Change Log
Unreleased
----------

[8.5.0] - 2023-06-08
[8.5.0] - 2023-08-08
--------------------
Changed
~~~~~~~
Expand Down
12 changes: 6 additions & 6 deletions openedx_events/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class EventsMetadata:
validator=attr.validators.instance_of(tuple),
)

def as_json(self):
def as_json_data(self):
"""
Convert instance to json-compatible dictionary.
Returns a json-compatible dictionary of the instance.
"""
def value_serializer(inst, field, value): # pylint: disable="unused-argument"
if isinstance(value, UUID):
Expand All @@ -99,14 +99,14 @@ def value_serializer(inst, field, value): # pylint: disable="unused-argument"
return value
return attrs.asdict(self, value_serializer=value_serializer)

def as_json_string(self):
def as_json(self):
"""
Convert instance to json string.
Serialize instance to json string.
"""
return json.dumps(self.as_json())
return json.dumps(self.as_json_data())

@classmethod
def from_json_string(cls, json_string):
def from_json(cls, json_string):
"""
Create an instance from a json string.
Expand Down
4 changes: 2 additions & 2 deletions openedx_events/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ def setUp(self) -> None:
)

def test_events_metadata_to_and_from_json(self):
as_json = self.metadata.as_json_string()
from_json = EventsMetadata.from_json_string(as_json)
as_json = self.metadata.as_json()
from_json = EventsMetadata.from_json(as_json)
self.assertEqual(self.metadata, from_json)

0 comments on commit 663281e

Please sign in to comment.