diff --git a/watch/watch_test.py b/watch/watch_test.py index 6fec23ec..f102274e 100644 --- a/watch/watch_test.py +++ b/watch/watch_test.py @@ -110,6 +110,7 @@ def test_watch_resource_version_set(self): '{"type": "ADDED", "object": {"metadata": {"name": "test3",' '"resourceVersion": "3"}, "spec": {}, "status": {}}}\n' ] + # return nothing on the first call and values on the second # this emulates a watch from a rv that returns nothing in the first k8s # watch reset and values later @@ -250,6 +251,24 @@ def test_unmarshal_with_custom_object(self): self.assertEqual("1", event['object']['metadata']['resourceVersion']) self.assertEqual("1", w.resource_version) + # ref: gh-982 + def test_unmarshal_with_object_literal(self): + from json import dumps + w = Watch() + simple_object = {'hello': 'world', 'object': {}} + object_literal = dumps(simple_object) + event = w.unmarshal_event(object_literal, 'str') + self.assertTrue(isinstance(event, str)) + self.assertEqual(object_literal, event) + + # ref: gh-983 + def test_unmarshal_with_int_literal(self): + w = Watch() + int_literal = '1145141919' + event = w.unmarshal_event(int_literal, 'str') + self.assertTrue(isinstance(event, str)) + self.assertEqual(int_literal, event) + def test_watch_with_exception(self): fake_resp = Mock() fake_resp.close = Mock()