def test_put_invalid_response(self):
test_data = {'test': 'test'}
def put(url, data, **kwargs):
return FakeResponse()
response = FakeResponse()
with patch.object(requests, 'put', side_effects=put, return_value=response) as mock_put:
test_path = 'test_path'
client = Client(TEST_API_URL, AUTH_HEADERS)
with self.assertRaises(InvalidJSONError):
client.put(test_path, data=test_data)
self.assertTrue(mock_put.called)
expected_url_call = TEST_API_URL + '/' + test_path
mock_put.assert_called_with(expected_url_call, data=test_data, headers=AUTH_HEADERS, auth=None)
评论列表
文章目录