Improve 404 handling
This commit is contained in:
parent
03dc6d92ae
commit
557f849519
@ -156,7 +156,7 @@ class ApiServer(RPC):
|
|||||||
"""
|
"""
|
||||||
return self.rest_dump({
|
return self.rest_dump({
|
||||||
'status': 'error',
|
'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
|
'code': 404
|
||||||
}), 404
|
}), 404
|
||||||
|
|
||||||
|
@ -29,6 +29,18 @@ def response_success_assert(response):
|
|||||||
assert response.content_type == "application/json"
|
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):
|
def test_api_stop_workflow(botclient):
|
||||||
ftbot, client = botclient
|
ftbot, client = botclient
|
||||||
assert ftbot.state == State.RUNNING
|
assert ftbot.state == State.RUNNING
|
||||||
|
Loading…
Reference in New Issue
Block a user