|
19 | 19 |
|
20 | 20 | from kubernetes import client, config |
21 | 21 | from kubernetes.client import ApiException |
| 22 | +from kubernetes.client.exceptions import ApiTypeError |
22 | 23 |
|
23 | 24 | from .watch import Watch |
24 | 25 |
|
@@ -223,6 +224,44 @@ def test_watch_for_follow(self): |
223 | 224 | fake_resp.close.assert_called_once() |
224 | 225 | fake_resp.release_conn.assert_called_once() |
225 | 226 |
|
| 227 | + def test_watch_for_follow_with_split_param_type_docstring(self): |
| 228 | + fake_resp = Mock() |
| 229 | + fake_resp.close = Mock() |
| 230 | + fake_resp.release_conn = Mock() |
| 231 | + fake_resp.stream = Mock( |
| 232 | + return_value=[ |
| 233 | + 'log_line_1\n', |
| 234 | + 'log_line_2\n']) |
| 235 | + |
| 236 | + def read_pod_log(*args, **kwargs): |
| 237 | + if 'watch' in kwargs: |
| 238 | + raise ApiTypeError( |
| 239 | + "Got an unexpected keyword argument 'watch'" |
| 240 | + " to method read_namespaced_pod_log") |
| 241 | + return fake_resp |
| 242 | + |
| 243 | + fake_api = Mock() |
| 244 | + fake_api.read_namespaced_pod_log = Mock(side_effect=read_pod_log) |
| 245 | + fake_api.read_namespaced_pod_log.__doc__ = ( |
| 246 | + ':param follow: Follow the log stream of the pod. Defaults to false.\n' |
| 247 | + ':type follow: bool\n' |
| 248 | + ':rtype: str') |
| 249 | + |
| 250 | + w = Watch() |
| 251 | + count = 1 |
| 252 | + for e in w.stream(fake_api.read_namespaced_pod_log): |
| 253 | + self.assertEqual("log_line_1", e) |
| 254 | + count += 1 |
| 255 | + if count == 2: |
| 256 | + w.stop() |
| 257 | + |
| 258 | + fake_api.read_namespaced_pod_log.assert_called_once_with( |
| 259 | + _preload_content=False, follow=True) |
| 260 | + fake_resp.stream.assert_called_once_with( |
| 261 | + amt=None, decode_content=False) |
| 262 | + fake_resp.close.assert_called_once() |
| 263 | + fake_resp.release_conn.assert_called_once() |
| 264 | + |
226 | 265 | def test_watch_resource_version_set(self): |
227 | 266 | # https://github.com/kubernetes-client/python/issues/700 |
228 | 267 | # ensure watching from a resource version does reset to resource |
|
0 commit comments