diff --git a/.gitignore b/.gitignore index 07d59bc..bdf590d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ _trial_temp .cache/ .coverage ve/ +.vscode diff --git a/junebug/api.py b/junebug/api.py index a4c5933..0a44a75 100644 --- a/junebug/api.py +++ b/junebug/api.py @@ -699,7 +699,8 @@ def return_queue_results(results): 'name': queue['name'], 'stuck': False, 'messages': queue.get('messages'), - 'rate': queue['messages_details']['rate'] + 'rate': + queue['messages_stats']['ack_details']['rate'] } if (details['messages'] > 0 and details['rate'] == 0): stuck = True diff --git a/junebug/tests/test_api.py b/junebug/tests/test_api.py index 0b29b44..c3da4d7 100644 --- a/junebug/tests/test_api.py +++ b/junebug/tests/test_api.py @@ -78,7 +78,7 @@ def assert_response(self, response, code, description, result, ignore=[]): self.assertEqual(data, { 'status': code, - 'code': http.RESPONSES[code], + 'code': http.RESPONSES.get(code, code), 'description': description, 'result': result, }) @@ -88,12 +88,12 @@ def test_http_error(self): resp = yield self.get('/foobar') yield self.assert_response( resp, http.NOT_FOUND, - 'The requested URL was not found on the server. If you entered ' + 'The requested URL was not found on the server. If you entered ' 'the URL manually please check your spelling and try again.', { 'errors': [{ 'code': 404, 'message': ('404 Not Found: The requested URL was not ' - 'found on the server. If you entered the URL' + 'found on the server. If you entered the URL' ' manually please check your spelling and try' ' again.'), 'type': 'Not Found', @@ -103,20 +103,16 @@ def test_http_error(self): @inlineCallbacks def test_redirect_http_error(self): resp = yield self.get('/channels') - [redirect] = resp.history() yield self.assert_response( - redirect, http.MOVED_PERMANENTLY, + resp, 308, None, { 'errors': [{ - 'code': 301, - 'message': '301 Moved Permanently: None', + 'code': 308, + 'message': '308 Permanent Redirect: None', 'new_url': '%s/channels/' % self.url, - 'type': 'Moved Permanently', + 'type': 'Permanent Redirect', }], }) - yield self.assert_response( - resp, http.OK, - 'channels listed', []) @inlineCallbacks def test_invalid_json_handling(self): @@ -1048,7 +1044,7 @@ def test_get_channels_health_check(self): request_list.append( ((b'get', url, mock.ANY, mock.ANY, mock.ANY), (http.OK, {b'Content-Type': b'application/json'}, - b'{"messages": 1256, "messages_details": {"rate": 1.25}, "name": "%s"}' % queue_name))) # noqa + b'{"messages": 1256, "messages_stats": {"ack_details": {"rate": 1.25}}, "name": "%s"}' % queue_name))) # noqa async_failures = [] sequence_stubs = RequestSequence(request_list, async_failures.append) @@ -1112,7 +1108,7 @@ def test_get_channels_and_destinations_health_check(self): request_list.append( ((b'get', url, mock.ANY, mock.ANY, mock.ANY), (http.OK, {b'Content-Type': b'application/json'}, - b'{"messages": 1256, "messages_details": {"rate": 1.25}, "name": "%s"}' % queue_name))) # noqa + b'{"messages": 1256, "messages_stats": {"ack_details": {"rate": 1.25}}, "name": "%s"}' % queue_name))) # noqa response.append({ 'messages': 1256, @@ -1154,7 +1150,7 @@ def test_get_channels_health_check_stuck(self): request_list.append( ((b'get', url, mock.ANY, mock.ANY, mock.ANY), (http.OK, {b'Content-Type': b'application/json'}, - b'{"messages": 1256, "messages_details": {"rate": 0}, "name": "%s"}' % queue_name))) # noqa + b'{"messages": 1256, "messages_stats": {"ack_details": {"rate": 0.0}}, "name": "%s"}' % queue_name))) # noqa async_failures = [] sequence_stubs = RequestSequence(request_list, async_failures.append) diff --git a/junebug/utils.py b/junebug/utils.py index cf853a7..99dacc4 100644 --- a/junebug/utils.py +++ b/junebug/utils.py @@ -14,7 +14,7 @@ def response(req, description, data, code=http.OK): return json.dumps({ 'status': code, - 'code': http.RESPONSES[code], + 'code': http.RESPONSES.get(code, code), 'description': description, 'result': data, }, cls=JSONMessageEncoder)