File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments