Skip to content

Commit

Permalink
Add tests of unmarshaling literals to watch.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahuif committed Oct 23, 2019
1 parent a2d1024 commit 28c0eaf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions watch/watch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,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_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()
Expand Down

0 comments on commit 28c0eaf

Please sign in to comment.