def test_http_put_method(self): data = {"test": "json_request"} return_data = { "request-id": "20160927110557057580971", "result": { "error-code": "NAL100000", "message": "", "status": "success" } } fake = utils.FakeResponse({}, json.dumps(return_data)) requests.Session.request(mox.IgnoreArg(), mox.IgnoreArg(), stream=mox.IgnoreArg(), data=json.dumps(data), headers=mox.IgnoreArg()).AndReturn(fake) self.mock.ReplayAll() body = self.client.put('v1/node/', data=data) self.assertEqual(return_data, body)
def test_http_nal_api_error(self): data = {"test": "json_request"} return_data = { "request-id": "20160927110557057580971", "result": { "error-code": "NAL110001", "message": "", "status": "success" } } fake = utils.FakeResponse({}, json.dumps(return_data)) requests.Session.request(mox.IgnoreArg(), mox.IgnoreArg(), stream=mox.IgnoreArg(), data=json.dumps(data), headers=mox.IgnoreArg()).AndReturn(fake) self.mock.ReplayAll() self.assertRaises(exc.NalBadRequest, self.client.post, '/v1/node/', data=data)