Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Commit 758d55e

Browse files
committed
Add tests of unmarshaling literals to watch.py
see #171 see kubernetes-client/python#982 see kubernetes-client/python#983
1 parent a2d1024 commit 758d55e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: watch/watch_test.py

+19
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def test_watch_resource_version_set(self):
110110
'{"type": "ADDED", "object": {"metadata": {"name": "test3",'
111111
'"resourceVersion": "3"}, "spec": {}, "status": {}}}\n'
112112
]
113+
113114
# return nothing on the first call and values on the second
114115
# this emulates a watch from a rv that returns nothing in the first k8s
115116
# watch reset and values later
@@ -250,6 +251,24 @@ def test_unmarshal_with_custom_object(self):
250251
self.assertEqual("1", event['object']['metadata']['resourceVersion'])
251252
self.assertEqual("1", w.resource_version)
252253

254+
# ref: gh-982
255+
def test_unmarshal_with_object_literal(self):
256+
from json import dumps
257+
w = Watch()
258+
simple_object = {'hello': 'world', 'object': {}}
259+
object_literal = dumps(simple_object)
260+
event = w.unmarshal_event(object_literal, 'str')
261+
self.assertTrue(isinstance(event, str))
262+
self.assertEqual(object_literal, event)
263+
264+
# ref: gh-983
265+
def test_unmarshal_with_int_literal(self):
266+
w = Watch()
267+
int_literal = '1145141919'
268+
event = w.unmarshal_event(int_literal, 'str')
269+
self.assertTrue(isinstance(event, str))
270+
self.assertEqual(int_literal, event)
271+
253272
def test_watch_with_exception(self):
254273
fake_resp = Mock()
255274
fake_resp.close = Mock()

0 commit comments

Comments
 (0)