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")
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')
def test_deserialize_invalid_json(self): result = deserialize('{"test"}') self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 0)
def test_deserialize_non_string(self): result = deserialize({"test": "test"}) self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 0)
def test_deserialize_none(self): result = deserialize(None) self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 0)
def test_deserialize_empty_string(self): result = deserialize("") self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 0)
def test_deserialize_non_json(self): result = deserialize("<html></html>") self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 0)
def test_deserialize_non_string(self): result = deserialize({'test': 'test'}) self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 0)
def test_deserialize_empty_string(self): result = deserialize('') self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 0)
def test_deserialize_non_json(self): result = deserialize('<html></html>') self.assertTrue(isinstance(result, dict)) self.assertEqual(len(result), 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