Skip to content

Commit

Permalink
fix http error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikh360 committed Apr 17, 2020
1 parent e41ffc0 commit 7003e87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions junebug/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -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',
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion junebug/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7003e87

Please sign in to comment.