Пример #1
0
 def test_json_valid_utf8(self):
     data = """{"server": {"min_count": 1, "flavorRef": "1",
             "name": "\xe6\xa6\x82\xe5\xbf\xb5",
             "imageRef": "10bab10c-1304-47d",
             "max_count": 1}} """
     as_dict = {
         'body': {
             u'server': {
                         u'min_count': 1, u'flavorRef': u'1',
                         u'name': u'\u6982\u5ff5',
                         u'imageRef': u'10bab10c-1304-47d',
                         u'max_count': 1
                        }
                 }
         }
     deserializer = wsgi.JSONDeserializer()
     self.assertEqual(deserializer.deserialize(data), as_dict)
Пример #2
0
 def test_json(self):
     data = """{"a": {
             "a1": "1",
             "a2": "2",
             "bs": ["1", "2", "3", {"c": {"c1": "1"}}],
             "d": {"e": "1"},
             "f": "1"}}"""
     as_dict = {
         'body': {
             'a': {
                 'a1': '1',
                 'a2': '2',
                 'bs': ['1', '2', '3', {'c': {'c1': '1'}}],
                 'd': {'e': '1'},
                 'f': '1',
             },
         },
     }
     deserializer = wsgi.JSONDeserializer()
     self.assertEqual(deserializer.deserialize(data), as_dict)