Skip to content

Commit 2a72447

Browse files
committed
chore: cleanup
1 parent 19e4c7f commit 2a72447

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

tests/py/unit/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class ExampleDoubleNestedKeyAsClassInstancesClass(ExampleDoubleNestedSchema, InM
5757

5858

5959
class SampleEnum(str, Enum):
60-
TRI = "TRI"
61-
ANGSTROM = "angstrom"
60+
VALUE1 = "value1"
61+
VALUE2 = "value2"
6262

6363

6464
class SampleModelWithEnum(BaseModel):

tests/py/unit/test_entity.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,13 @@ def test_to_dict():
168168

169169

170170
def test_to_dict_with_enum():
171-
"""Test that enums are serialized as strings in to_dict()"""
172-
entity = SampleEntityWithEnum(type=SampleEnum.TRI, name="example")
171+
entity = SampleEntityWithEnum(type=SampleEnum.VALUE1, name="example")
173172
result = entity.to_dict()
174173

175174
assert isinstance(result, dict)
176-
assert result == {"type": "TRI", "name": "example"}
177-
assert result["type"] == "TRI" # String, not enum object
178-
179-
180-
def test_to_dict_with_enum_exclude():
181-
"""Test to_dict with exclude parameter works with enums"""
182-
entity = SampleEntityWithEnum(type=SampleEnum.ANGSTROM, name="test")
183-
result = entity.to_dict(exclude=["name"])
184-
185-
assert isinstance(result, dict)
186-
assert result == {"type": "angstrom"}
187-
assert result["type"] == "angstrom" # String, not enum object
175+
assert not isinstance(result["type"], SampleEnum) # Should not be an enum object
176+
assert result == {"type": "value1", "name": "example"}
177+
assert result["type"] == "value1" # String, not enum object
188178

189179

190180
def test_to_json():

0 commit comments

Comments
 (0)