예제 #1
0
    def test_deserialize(self):
        json_str = '{"firstname": "Test", "lastname": "Test last"}'
        user_dict = deserialize(json_str)

        self.assertIn("firstname", user_dict)
        self.assertEqual(user_dict["firstname"], "Test")
        self.assertEqual(user_dict["lastname"], "Test last")
예제 #2
0
    def test_deserialize(self):
        json_str = '{"firstname": "Test", "lastname": "Test last"}'
        user_dict = deserialize(json_str)

        self.assertIn('firstname', user_dict)
        self.assertEqual(user_dict['firstname'], 'Test')
        self.assertEqual(user_dict['lastname'], 'Test last')
예제 #3
0
 def test_deserialize_invalid_json(self):
     result = deserialize('{"test"}')
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #4
0
 def test_deserialize_non_string(self):
     result = deserialize({"test": "test"})
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #5
0
 def test_deserialize_none(self):
     result = deserialize(None)
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #6
0
 def test_deserialize_empty_string(self):
     result = deserialize("")
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #7
0
 def test_deserialize_non_json(self):
     result = deserialize("<html></html>")
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #8
0
 def test_deserialize_non_string(self):
     result = deserialize({'test': 'test'})
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #9
0
 def test_deserialize_invalid_json(self):
     result = deserialize('{"test"}')
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #10
0
 def test_deserialize_none(self):
     result = deserialize(None)
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #11
0
 def test_deserialize_empty_string(self):
     result = deserialize('')
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #12
0
 def test_deserialize_non_json(self):
     result = deserialize('<html></html>')
     self.assertTrue(isinstance(result, dict))
     self.assertEqual(len(result), 0)
예제 #13
0
 def _process_response(response):
     """Do things with the response from requests"""
     if response is None:
         return None, None
     response_dict = deserialize(response.content)
     return response_dict, response.status_code
예제 #14
0
 def _process_response(response):
     """Do things with the response from requests"""
     if response is None:
         return None, None
     response_dict = deserialize(response.content)
     return response_dict, response.status_code