This repository was archived by the owner on Mar 13, 2022. It is now read-only.
File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 18
18
19
19
from mock import Mock , call
20
20
21
+ from kubernetes import client
22
+
21
23
from .watch import Watch
22
24
23
25
@@ -275,6 +277,31 @@ def test_watch_with_exception(self):
275
277
fake_resp .close .assert_called_once ()
276
278
fake_resp .release_conn .assert_called_once ()
277
279
280
+ def test_watch_with_error_event (self ):
281
+ fake_resp = Mock ()
282
+ fake_resp .close = Mock ()
283
+ fake_resp .release_conn = Mock ()
284
+ fake_resp .read_chunked = Mock (
285
+ return_value = [
286
+ '{"type": "ERROR", "object": {"code": 410, '
287
+ '"reason": "Gone", "message": "error message"}}\n ' ])
288
+
289
+ fake_api = Mock ()
290
+ fake_api .get_thing = Mock (return_value = fake_resp )
291
+
292
+ w = Watch ()
293
+ try :
294
+ for _ in w .stream (fake_api .get_thing ):
295
+ self .fail (self , "Should fail with ApiException." )
296
+ except client .rest .ApiException :
297
+ pass
298
+
299
+ fake_api .get_thing .assert_called_once_with (
300
+ _preload_content = False , watch = True )
301
+ fake_resp .read_chunked .assert_called_once_with (decode_content = False )
302
+ fake_resp .close .assert_called_once ()
303
+ fake_resp .release_conn .assert_called_once ()
304
+
278
305
279
306
if __name__ == '__main__' :
280
307
unittest .main ()
You can’t perform that action at this time.
0 commit comments