Skip to content

Commit 662ab21

Browse files
committed
fixed watch_test, event is a dict, not an object
1 parent 56951f2 commit 662ab21

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

kubernetes/base/watch/watch_test.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ def test_watch_with_decode(self):
4545

4646
fake_api = Mock()
4747
fake_api.get_namespaces = Mock(return_value=fake_resp)
48-
fake_api.get_namespaces.__doc__ = ':return: V1NamespaceList'
48+
fake_api.get_namespaces.__doc__ = ':rtype: V1NamespaceList'
4949

5050
w = Watch()
5151
count = 1
5252
for e in w.stream(fake_api.get_namespaces):
5353
self.assertEqual("ADDED", e['type'])
5454
# make sure decoder worked and we got a model with the right name
55-
self.assertEqual("test%d" % count, e['object'].metadata.name)
55+
self.assertEqual("test%d" % count, e['object']['metadata']['name'])
5656
# make sure decoder worked and updated Watch.resource_version
5757
self.assertEqual(
58-
"%d" % count, e['object'].metadata.resource_version)
58+
"%d" % count, e['object']['metadata']['resourceVersion'])
5959
self.assertEqual("%d" % count, w.resource_version)
6060
count += 1
6161
# make sure we can stop the watch and the last event with won't be
@@ -92,7 +92,7 @@ def test_watch_with_interspersed_newlines(self):
9292

9393
fake_api = Mock()
9494
fake_api.get_namespaces = Mock(return_value=fake_resp)
95-
fake_api.get_namespaces.__doc__ = ':return: V1NamespaceList'
95+
fake_api.get_namespaces.__doc__ = ':rtype: V1NamespaceList'
9696

9797
w = Watch()
9898
count = 0
@@ -105,7 +105,7 @@ def test_watch_with_interspersed_newlines(self):
105105
if e is None:
106106
continue
107107
count += 1
108-
self.assertEqual("test%d" % count, e['object'].metadata.name)
108+
self.assertEqual("test%d" % count, e['object']['metadata']['name'])
109109
self.assertEqual(3, count)
110110

111111
def test_watch_with_multibyte_utf8(self):
@@ -129,7 +129,7 @@ def test_watch_with_multibyte_utf8(self):
129129

130130
fake_api = Mock()
131131
fake_api.get_configmaps = Mock(return_value=fake_resp)
132-
fake_api.get_configmaps.__doc__ = ':return: V1ConfigMapList'
132+
fake_api.get_configmaps.__doc__ = ':rtype: V1ConfigMapList'
133133

134134
w = Watch()
135135
count = 0
@@ -140,10 +140,10 @@ def test_watch_with_multibyte_utf8(self):
140140
for event in w.stream(fake_api.get_configmaps, timeout_seconds=1):
141141
count += 1
142142
self.assertEqual("MODIFIED", event['type'])
143-
self.assertEqual("test%d" % count, event['object'].metadata.name)
144-
self.assertEqual("© %d" % count, event['object'].data["utf-8"])
143+
self.assertEqual("test%d" % count, event['object']['metadata']['name'])
144+
self.assertEqual("© %d" % count, event['object']['data']["utf-8"])
145145
self.assertEqual(
146-
"%d" % count, event['object'].metadata.resource_version)
146+
"%d" % count, event['object']['metadata']['resourceVersion'])
147147
self.assertEqual("%d" % count, w.resource_version)
148148
self.assertEqual(3, count)
149149

@@ -175,7 +175,7 @@ def test_watch_with_invalid_utf8(self):
175175

176176
fake_api = Mock()
177177
fake_api.get_configmaps = Mock(return_value=fake_resp)
178-
fake_api.get_configmaps.__doc__ = ':return: V1ConfigMapList'
178+
fake_api.get_configmaps.__doc__ = ':rtype: V1ConfigMapList'
179179

180180
w = Watch()
181181
count = 0
@@ -186,11 +186,11 @@ def test_watch_with_invalid_utf8(self):
186186
for event in w.stream(fake_api.get_configmaps, timeout_seconds=1):
187187
count += 1
188188
self.assertEqual("MODIFIED", event['type'])
189-
self.assertEqual("test%d" % count, event['object'].metadata.name)
190-
self.assertEqual("😄 %d" % count, event['object'].data["utf-8"])
189+
self.assertEqual("test%d" % count, event['object']['metadata']['name'])
190+
self.assertEqual("😄 %d" % count, event['object']['data']["utf-8"])
191191
# expect N replacement characters in test N
192192
self.assertEqual("� %d".replace('�', '�'*count) %
193-
count, event['object'].data["invalid"])
193+
count, event['object']['data']["invalid"])
194194
self.assertEqual(3, count)
195195

196196
def test_watch_for_follow(self):
@@ -204,7 +204,7 @@ def test_watch_for_follow(self):
204204

205205
fake_api = Mock()
206206
fake_api.read_namespaced_pod_log = Mock(return_value=fake_resp)
207-
fake_api.read_namespaced_pod_log.__doc__ = ':param bool follow:\n:return: str'
207+
fake_api.read_namespaced_pod_log.__doc__ = ':param bool follow:\n:rtype: str'
208208

209209
w = Watch()
210210
count = 1
@@ -256,7 +256,7 @@ def get_values(*args, **kwargs):
256256

257257
fake_api = Mock()
258258
fake_api.get_namespaces = Mock(return_value=fake_resp)
259-
fake_api.get_namespaces.__doc__ = ':return: V1NamespaceList'
259+
fake_api.get_namespaces.__doc__ = ':rtype: V1NamespaceList'
260260

261261
w = Watch()
262262
# ensure we keep our requested resource version or the version latest
@@ -303,7 +303,7 @@ def test_watch_stream_twice(self):
303303

304304
fake_api = Mock()
305305
fake_api.get_namespaces = Mock(return_value=fake_resp)
306-
fake_api.get_namespaces.__doc__ = ':return: V1NamespaceList'
306+
fake_api.get_namespaces.__doc__ = ':rtype: V1NamespaceList'
307307

308308
count = 1
309309
for e in w.stream(fake_api.get_namespaces):
@@ -330,7 +330,7 @@ def test_watch_stream_loop(self):
330330

331331
fake_api = Mock()
332332
fake_api.get_namespaces = Mock(return_value=fake_resp)
333-
fake_api.get_namespaces.__doc__ = ':return: V1NamespaceList'
333+
fake_api.get_namespaces.__doc__ = ':rtype: V1NamespaceList'
334334

335335
count = 0
336336

@@ -597,7 +597,7 @@ def test_pod_log_empty_lines(self):
597597
#
598598
# fake_api = Mock()
599599
# fake_api.get_namespaces = Mock(return_value=fake_resp)
600-
# fake_api.get_namespaces.__doc__ = ':return: V1NamespaceList'
600+
# fake_api.get_namespaces.__doc__ = ':rtype: V1NamespaceList'
601601
#
602602
# # test case with deserialize=True
603603
# w = Watch()

0 commit comments

Comments
 (0)