@@ -30,7 +30,7 @@ def test_watch_with_decode(self):
3030 fake_resp = Mock ()
3131 fake_resp .close = Mock ()
3232 fake_resp .release_conn = Mock ()
33- fake_resp .read_chunked = Mock (
33+ fake_resp .stream = Mock (
3434 return_value = [
3535 '{"type": "ADDED", "object": {"metadata": {"name": "test1",'
3636 '"resourceVersion": "1"}, "spec": {}, "status": {}}}\n ' ,
@@ -63,15 +63,16 @@ def test_watch_with_decode(self):
6363
6464 fake_api .get_namespaces .assert_called_once_with (
6565 _preload_content = False , watch = True )
66- fake_resp .read_chunked .assert_called_once_with (decode_content = False )
66+ fake_resp .stream .assert_called_once_with (
67+ amt = None , decode_content = False )
6768 fake_resp .close .assert_called_once ()
6869 fake_resp .release_conn .assert_called_once ()
6970
7071 def test_watch_for_follow (self ):
7172 fake_resp = Mock ()
7273 fake_resp .close = Mock ()
7374 fake_resp .release_conn = Mock ()
74- fake_resp .read_chunked = Mock (
75+ fake_resp .stream = Mock (
7576 return_value = [
7677 'log_line_1\n ' ,
7778 'log_line_2\n ' ])
@@ -92,7 +93,8 @@ def test_watch_for_follow(self):
9293
9394 fake_api .read_namespaced_pod_log .assert_called_once_with (
9495 _preload_content = False , follow = True )
95- fake_resp .read_chunked .assert_called_once_with (decode_content = False )
96+ fake_resp .stream .assert_called_once_with (
97+ amt = None , decode_content = False )
9698 fake_resp .close .assert_called_once ()
9799 fake_resp .release_conn .assert_called_once ()
98100
@@ -112,6 +114,7 @@ def test_watch_resource_version_set(self):
112114 '{"type": "ADDED", "object": {"metadata": {"name": "test3",'
113115 '"resourceVersion": "3"}, "spec": {}, "status": {}}}\n '
114116 ]
117+
115118 # return nothing on the first call and values on the second
116119 # this emulates a watch from a rv that returns nothing in the first k8s
117120 # watch reset and values later
@@ -123,7 +126,7 @@ def get_values(*args, **kwargs):
123126 else :
124127 return values
125128
126- fake_resp .read_chunked = Mock (
129+ fake_resp .stream = Mock (
127130 side_effect = get_values )
128131
129132 fake_api = Mock ()
@@ -170,7 +173,7 @@ def test_watch_stream_twice(self):
170173 fake_resp = Mock ()
171174 fake_resp .close = Mock ()
172175 fake_resp .release_conn = Mock ()
173- fake_resp .read_chunked = Mock (
176+ fake_resp .stream = Mock (
174177 return_value = ['{"type": "ADDED", "object": 1}\n ' ] * 4 )
175178
176179 fake_api = Mock ()
@@ -186,8 +189,8 @@ def test_watch_stream_twice(self):
186189 self .assertEqual (count , 3 )
187190 fake_api .get_namespaces .assert_called_once_with (
188191 _preload_content = False , watch = True )
189- fake_resp .read_chunked .assert_called_once_with (
190- decode_content = False )
192+ fake_resp .stream .assert_called_once_with (
193+ amt = None , decode_content = False )
191194 fake_resp .close .assert_called_once ()
192195 fake_resp .release_conn .assert_called_once ()
193196
@@ -197,7 +200,7 @@ def test_watch_stream_loop(self):
197200 fake_resp = Mock ()
198201 fake_resp .close = Mock ()
199202 fake_resp .release_conn = Mock ()
200- fake_resp .read_chunked = Mock (
203+ fake_resp .stream = Mock (
201204 return_value = ['{"type": "ADDED", "object": 1}\n ' ])
202205
203206 fake_api = Mock ()
@@ -219,7 +222,7 @@ def test_watch_stream_loop(self):
219222
220223 self .assertEqual (count , 2 )
221224 self .assertEqual (fake_api .get_namespaces .call_count , 2 )
222- self .assertEqual (fake_resp .read_chunked .call_count , 2 )
225+ self .assertEqual (fake_resp .stream .call_count , 2 )
223226 self .assertEqual (fake_resp .close .call_count , 2 )
224227 self .assertEqual (fake_resp .release_conn .call_count , 2 )
225228
@@ -256,7 +259,7 @@ def test_watch_with_exception(self):
256259 fake_resp = Mock ()
257260 fake_resp .close = Mock ()
258261 fake_resp .release_conn = Mock ()
259- fake_resp .read_chunked = Mock (side_effect = KeyError ('expected' ))
262+ fake_resp .stream = Mock (side_effect = KeyError ('expected' ))
260263
261264 fake_api = Mock ()
262265 fake_api .get_thing = Mock (return_value = fake_resp )
@@ -271,15 +274,16 @@ def test_watch_with_exception(self):
271274
272275 fake_api .get_thing .assert_called_once_with (
273276 _preload_content = False , watch = True )
274- fake_resp .read_chunked .assert_called_once_with (decode_content = False )
277+ fake_resp .stream .assert_called_once_with (
278+ amt = None , decode_content = False )
275279 fake_resp .close .assert_called_once ()
276280 fake_resp .release_conn .assert_called_once ()
277281
278282 def test_watch_with_error_event (self ):
279283 fake_resp = Mock ()
280284 fake_resp .close = Mock ()
281285 fake_resp .release_conn = Mock ()
282- fake_resp .read_chunked = Mock (
286+ fake_resp .stream = Mock (
283287 return_value = [
284288 '{"type": "ERROR", "object": {"code": 410, '
285289 '"reason": "Gone", "message": "error message"}}\n ' ])
@@ -294,15 +298,16 @@ def test_watch_with_error_event(self):
294298
295299 fake_api .get_thing .assert_called_once_with (
296300 _preload_content = False , watch = True )
297- fake_resp .read_chunked .assert_called_once_with (decode_content = False )
301+ fake_resp .stream .assert_called_once_with (
302+ amt = None , decode_content = False )
298303 fake_resp .close .assert_called_once ()
299304 fake_resp .release_conn .assert_called_once ()
300305
301306 def test_watch_retries_on_error_event (self ):
302307 fake_resp = Mock ()
303308 fake_resp .close = Mock ()
304309 fake_resp .release_conn = Mock ()
305- fake_resp .read_chunked = Mock (
310+ fake_resp .stream = Mock (
306311 return_value = [
307312 '{"type": "ERROR", "object": {"code": 410, '
308313 '"reason": "Gone", "message": "error message"}}\n ' ])
@@ -320,16 +325,16 @@ def test_watch_retries_on_error_event(self):
320325 # Two calls should be expected during a retry
321326 fake_api .get_thing .assert_has_calls (
322327 [call (resource_version = 0 , _preload_content = False , watch = True )] * 2 )
323- fake_resp .read_chunked .assert_has_calls (
324- [call (decode_content = False )] * 2 )
328+ fake_resp .stream .assert_has_calls (
329+ [call (amt = None , decode_content = False )] * 2 )
325330 assert fake_resp .close .call_count == 2
326331 assert fake_resp .release_conn .call_count == 2
327332
328333 def test_watch_with_error_event_and_timeout_param (self ):
329334 fake_resp = Mock ()
330335 fake_resp .close = Mock ()
331336 fake_resp .release_conn = Mock ()
332- fake_resp .read_chunked = Mock (
337+ fake_resp .stream = Mock (
333338 return_value = [
334339 '{"type": "ERROR", "object": {"code": 410, '
335340 '"reason": "Gone", "message": "error message"}}\n ' ])
@@ -346,7 +351,8 @@ def test_watch_with_error_event_and_timeout_param(self):
346351
347352 fake_api .get_thing .assert_called_once_with (
348353 _preload_content = False , watch = True , timeout_seconds = 10 )
349- fake_resp .read_chunked .assert_called_once_with (decode_content = False )
354+ fake_resp .stream .assert_called_once_with (
355+ amt = None , decode_content = False )
350356 fake_resp .close .assert_called_once ()
351357 fake_resp .release_conn .assert_called_once ()
352358
0 commit comments