def test_unmarshal_with_float_object(self):
     w = Watch()
     event = w.unmarshal_event('{"type": "ADDED", "object": 1}', 'float')
     self.assertEqual("ADDED", event['type'])
     self.assertEqual(1.0, event['object'])
     self.assertTrue(isinstance(event['object'], float))
     self.assertEqual(1, event['raw_object'])
 def test_unmarshal_with_no_return_type(self):
     w = Watch()
     event = w.unmarshal_event('{"type": "ADDED", "object": ["test1"]}',
                               None)
     self.assertEqual("ADDED", event['type'])
     self.assertEqual(["test1"], event['object'])
     self.assertEqual(["test1"], event['raw_object'])
Beispiel #3
0
 def test_unmarshal_with_empty_return_type(self):
     # empty string as a return_type is a default value
     # if watch can't detect object by function's name
     w = Watch()
     event = w.unmarshal_event('{"type": "ADDED", "object": ["test1"]}', '')
     self.assertEqual("ADDED", event['type'])
     self.assertEqual(["test1"], event['object'])
     self.assertEqual(["test1"], event['raw_object'])
 def test_unmarshal_with_custom_object(self):
     w = Watch()
     event = w.unmarshal_event(
         '{"type": "ADDED", "object": {"apiVersion":'
         '"test.com/v1beta1","kind":"foo","metadata":'
         '{"name": "bar", "resourceVersion": "1"}}}', 'object')
     self.assertEqual("ADDED", event['type'])
     # make sure decoder deserialized json into dictionary and updated
     # Watch.resource_version
     self.assertTrue(isinstance(event['object'], dict))
     self.assertEqual("1", event['object']['metadata']['resourceVersion'])
     self.assertEqual("1", w.resource_version)