Skip to content

Commit

Permalink
finalize utility
Browse files Browse the repository at this point in the history
  • Loading branch information
shay-te committed Nov 23, 2023
1 parent ea57001 commit 4aa2005
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions core_lib/data_transform/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def set_dict_attr(obj: dict, path: str, value) -> dict:

def enum_to_dict(enum: enum) -> dict:
result = {}
enum_name = camel_to_snake(enum.__name__).lower()
for name, enumItem in enum.__members__.items():
result[name] = enumItem.value
return {enum_name: result}
return result
6 changes: 2 additions & 4 deletions tests/test_data_transform_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,13 @@ class CarsTypes(enum.Enum):
VOLVO = 2

converted_enum = enum_to_dict(Animals)
self.assertIn('animals', converted_enum)
self.assertDictEqual(converted_enum['animals'], {
self.assertDictEqual(converted_enum, {
Animals.DOG.name: Animals.DOG.value,
Animals.CAT.name: Animals.CAT.value,
Animals.BAT.name: Animals.BAT.value,
})
converted_enum = enum_to_dict(CarsTypes)
self.assertIn('cars_types', converted_enum)
self.assertDictEqual(converted_enum['cars_types'], {
self.assertDictEqual(converted_enum, {
CarsTypes.BMW.name: CarsTypes.BMW.value,
CarsTypes.TOYOTA.name: CarsTypes.TOYOTA.value,
CarsTypes.VOLVO.name: CarsTypes.VOLVO.value,
Expand Down

0 comments on commit 4aa2005

Please sign in to comment.