Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Commit ad06e5c

Browse files
committed
Added tests.
1 parent 8e6f043 commit ad06e5c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

watch/watch_test.py

+29
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,35 @@ def test_watch_with_decode(self):
6767
fake_resp.close.assert_called_once()
6868
fake_resp.release_conn.assert_called_once()
6969

70+
def test_watch_for_follow(self):
71+
fake_resp = Mock()
72+
fake_resp.close = Mock()
73+
fake_resp.release_conn = Mock()
74+
fake_resp.read_chunked = Mock(
75+
return_value=[
76+
'log_line_1\n',
77+
'log_line_2\n'])
78+
79+
fake_api = Mock()
80+
fake_api.read_namespaced_pod_log = Mock(return_value=fake_resp)
81+
fake_api.read_namespaced_pod_log.__doc__ = ':param bool follow:\n:return: str'
82+
83+
w = Watch()
84+
count = 1
85+
for e in w.stream(fake_api.read_namespaced_pod_log):
86+
self.assertEqual("log_line_1", e)
87+
count += 1
88+
# make sure we can stop the watch and the last event with won't be
89+
# returned
90+
if count == 2:
91+
w.stop()
92+
93+
fake_api.read_namespaced_pod_log.assert_called_once_with(
94+
_preload_content=False, follow=True)
95+
fake_resp.read_chunked.assert_called_once_with(decode_content=False)
96+
fake_resp.close.assert_called_once()
97+
fake_resp.release_conn.assert_called_once()
98+
7099
def test_watch_resource_version_set(self):
71100
# https://github.com/kubernetes-client/python/issues/700
72101
# ensure watching from a resource version does reset to resource

0 commit comments

Comments
 (0)