Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion coriolis/licensing/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def _raise_response_error(self, resp):
utils.get_exception_details(),
)
if error and all([x in error for x in ['code', 'message']]):
raise exception.Conflict(message=error['message'], code=int(error['code']))
exc = exception.LicensingException(message=error['message'])
exc.code = int(error['code'])
raise exc
else:
resp.raise_for_status()

Expand Down
17 changes: 17 additions & 0 deletions coriolis/tests/licensing/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ def test_raise_response_error_conflict(self):

mock_response.raise_for_status.assert_not_called()

def test_raise_response_error_forbidden(self):
mock_response = mock.Mock()
mock_response.json.return_value = {
'error': {
'code': 403,
'message': 'refreshing fulfilled Reservation is forbidden',
}
}

exc = self.assertRaises(
exception.LicensingException,
self.client._raise_response_error,
mock_response,
)
self.assertEqual(403, exc.code)
mock_response.raise_for_status.assert_not_called()

def test_raise_response_error_json_exception(self):
mock_response = mock.Mock()
mock_response.json.side_effect = KeyboardInterrupt()
Expand Down
Loading