Improve 404 handling

This commit is contained in:
Matthias 2019-05-11 13:18:11 +02:00
parent 03dc6d92ae
commit 557f849519
2 changed files with 13 additions and 1 deletions

View File

@ -156,7 +156,7 @@ class ApiServer(RPC):
"""
return self.rest_dump({
'status': 'error',
'reason': '''There's no API call for %s''' % request.base_url,
'reason': f"There's no API call for {request.base_url}.",
'code': 404
}), 404

View File

@ -29,6 +29,18 @@ def response_success_assert(response):
assert response.content_type == "application/json"
def test_api_not_found(botclient):
ftbot, client = botclient
rc = client.post("/invalid_url")
assert rc.status_code == 404
assert rc.content_type == "application/json"
assert rc.json == {'status': 'error',
'reason': "There's no API call for http://localhost/invalid_url.",
'code': 404
}
def test_api_stop_workflow(botclient):
ftbot, client = botclient
assert ftbot.state == State.RUNNING