Skip to content

Commit a858453

Browse files
Fix test_bookmark_advances_resource_version: set initial mock_w.resource_version to list RV and update in fake_stream
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com> Agent-Logs-Url: https://github.com/kubernetes-client/python/sessions/eed1f863-e80c-4b7a-9901-26288418183e
1 parent 6425bab commit a858453

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

kubernetes/test/test_informer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,15 @@ def test_bookmark_advances_resource_version(self):
389389

390390
with patch("kubernetes.informer.informer.Watch") as MockWatch:
391391
mock_w = MagicMock()
392-
# Simulate Watch.unmarshal_event updating resource_version on BOOKMARK.
393-
mock_w.resource_version = "100"
392+
# Start at the initial-list RV; fake_stream will advance it to the
393+
# BOOKMARK's RV, mirroring how Watch.unmarshal_event updates
394+
# self.resource_version before yielding a BOOKMARK event.
395+
mock_w.resource_version = "5"
394396

395397
def fake_stream(func, **kw):
398+
# Simulate Watch.unmarshal_event setting resource_version from
399+
# the BOOKMARK metadata before the event is yielded.
400+
mock_w.resource_version = "100"
396401
yield {"type": "BOOKMARK", "object": bookmark_obj, "raw_object": bookmark_obj}
397402
informer._stop_event.set()
398403

@@ -402,7 +407,8 @@ def fake_stream(func, **kw):
402407
informer.start()
403408
informer._thread.join(timeout=3)
404409

405-
# The informer must have synced the RV from the BOOKMARK.
410+
# The informer must have synced the RV from the BOOKMARK, not the
411+
# stale initial-list RV ("5").
406412
self.assertEqual(informer._resource_version, "100")
407413

408414
def test_bookmark_handler_receives_raw_dict(self):

0 commit comments

Comments
 (0)