Пример #1
0
 def test_deserializing_custom_wrapped_class(self):
     s = '{"specialName": {"attribute": 4}}'
     o = jsonify.deserialize(s, self.Named)
     self.assertTrue(isinstance(o, self.Named))
     self.assertEquals(o.attribute, 4)
Пример #2
0
 def test_deserialize(self):
     s = '{"klass": {"attribute": "value", "things": ["a", 2, "three"]}}'
     o = jsonify.deserialize(s, self.Klass)
     self.assertTrue(isinstance(o, self.Klass))
     self.assertEquals(o.attribute, 'value')
     self.assertEquals(o.things, ["a", 2, "three"])
Пример #3
0
 def test_deserializing_unwrapped_class(self):
     s = '{"attribute": 7}'
     o = jsonify.deserialize(s, self.Nameless)
     self.assertTrue(isinstance(o, self.Nameless))
     self.assertEquals(o.attribute, 7)
Пример #4
0
 def test_real_world_deserialization(self):
     o = jsonify.deserialize(self.serialized_request, self.AuthRequest)
     self.assertTrue(isinstance(o, self.AuthRequest))
     self.assertTrue(isinstance(o.credentials, self.AuthRequest.Credentials))
     self.assertEqual(o.credentials.username, 'joeuser')
     self.assertEqual(o.credentials.password, 'secrete')