Skip to content

Commit a86b02a

Browse files
committed
Fix incorrect object kind
1 parent 5abfa0f commit a86b02a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

ldclient/impl/datasourcev2/polling.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
DeleteObject,
2424
EventName,
2525
IntentCode,
26+
ObjectKind,
2627
Payload,
2728
PutObject,
2829
Selector,
@@ -478,9 +479,10 @@ def fdv1_polling_payload_to_changeset(data: dict) -> _Result[ChangeSet, str]:
478479
selector = Selector.no_selector()
479480

480481
# FDv1 uses "flags" instead of "features", so we need to map accordingly
482+
# Map FDv1 JSON keys to ObjectKind enum values
481483
kind_mappings = [
482-
(FEATURES, "flags"),
483-
(SEGMENTS, "segments")
484+
(ObjectKind.FLAG, "flags"),
485+
(ObjectKind.SEGMENT, "segments")
484486
]
485487

486488
for kind, fdv1_key in kind_mappings:

ldclient/testing/impl/datasourcev2/test_polling_payload_parsing.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
)
88
from ldclient.impl.datasystem.protocolv2 import ChangeType, ObjectKind
99
from ldclient.impl.util import _Fail, _Success
10-
from ldclient.versioned_data_kind import FEATURES, SEGMENTS
1110

1211

1312
def test_payload_is_missing_events_key():
@@ -195,7 +194,7 @@ def test_fdv1_payload_with_single_flag():
195194

196195
change = change_set.changes[0]
197196
assert change.action == ChangeType.PUT
198-
assert change.kind == FEATURES
197+
assert change.kind == ObjectKind.FLAG
199198
assert change.key == "test-flag"
200199
assert change.version == 1
201200

@@ -240,7 +239,7 @@ def test_fdv1_payload_with_single_segment():
240239

241240
change = change_set.changes[0]
242241
assert change.action == ChangeType.PUT
243-
assert change.kind == SEGMENTS
242+
assert change.kind == ObjectKind.SEGMENT
244243
assert change.key == "test-segment"
245244
assert change.version == 5
246245

@@ -263,8 +262,8 @@ def test_fdv1_payload_with_flags_and_segments():
263262
change_set = result.value
264263
assert len(change_set.changes) == 4
265264

266-
flag_changes = [c for c in change_set.changes if c.kind == FEATURES]
267-
segment_changes = [c for c in change_set.changes if c.kind == SEGMENTS]
265+
flag_changes = [c for c in change_set.changes if c.kind == ObjectKind.FLAG]
266+
segment_changes = [c for c in change_set.changes if c.kind == ObjectKind.SEGMENT]
268267

269268
assert len(flag_changes) == 2
270269
assert len(segment_changes) == 2

0 commit comments

Comments
 (0)