def test_request_failure(mock_request): mock_response = mock.create_autospec(requests.Response) mock_response.status_code = 400 mock_request.return_value = mock_response client = VCloudClient(HOST, VERSION, ORG) client.auth_token = 'test-token' with nose.tools.assert_raises(errors.VCloudAPIError): client.request('test-method', 'test-url')
def test_request(mock_request): mock_response = mock.create_autospec(requests.Response) mock_response.status_code = 200 mock_request.return_value = mock_response client = VCloudClient(HOST, VERSION, ORG) client.auth_token = 'test-token' assert client.request( 'test-method', 'test-url', headers={'test-header': 'test'})
def test_request_no_auth_token(mock_request): client = VCloudClient(HOST, VERSION, ORG) with nose.tools.assert_raises(errors.VCloudAuthError): client.request('test-method', 'test-url')