diff options
author | Guillaume Pasquet <dev@etenil.net> | 2022-02-20 09:30:46 +0000 |
---|---|---|
committer | Guillaume Pasquet <dev@etenil.net> | 2022-02-20 09:30:46 +0000 |
commit | f69d2801069850b48c6424b50d0107799d56e2f8 (patch) | |
tree | eaba8081a01fa69bcb23576daf6b3178e8c13765 /test_api | |
parent | ca6531ed467d1772f7b4afed05a69d666b071c14 (diff) |
Handle errors (more) gracefully
Diffstat (limited to 'test_api')
-rw-r--r-- | test_api/test_api.py | 19 | ||||
-rw-r--r-- | test_api/test_api_404_error.barb | 2 | ||||
-rw-r--r-- | test_api/test_api_500_error.barb | 2 | ||||
-rw-r--r-- | test_api/test_api_get.barb | 1 | ||||
-rw-r--r-- | test_api/test_api_nonexist_error.barb | 2 | ||||
-rw-r--r-- | test_api/test_api_post.barb | 3 |
6 files changed, 29 insertions, 0 deletions
diff --git a/test_api/test_api.py b/test_api/test_api.py new file mode 100644 index 0000000..bd8303d --- /dev/null +++ b/test_api/test_api.py @@ -0,0 +1,19 @@ +from bottle import get, post, run, HTTPError + +@get("/") +def get_root(): + return {"status": "OK"} + +@post("/") +def post_root(): + return {"status": "SUCCESS"} + +@get("/errors/404") +def error_404(): + raise HTTPError(404, body={"error": "no exist"}) + +@get("/errors/500") +def error_500(): + raise HTTPError(500, body={"error": "server error"}) + +run(host="localhost", port=8080) diff --git a/test_api/test_api_404_error.barb b/test_api/test_api_404_error.barb new file mode 100644 index 0000000..d2c9809 --- /dev/null +++ b/test_api/test_api_404_error.barb @@ -0,0 +1,2 @@ +#GET^http://localhost:8080/errors/404 + diff --git a/test_api/test_api_500_error.barb b/test_api/test_api_500_error.barb new file mode 100644 index 0000000..1017ab2 --- /dev/null +++ b/test_api/test_api_500_error.barb @@ -0,0 +1,2 @@ +#GET^http://localhost:8080/errors/500 + diff --git a/test_api/test_api_get.barb b/test_api/test_api_get.barb new file mode 100644 index 0000000..6bdf592 --- /dev/null +++ b/test_api/test_api_get.barb @@ -0,0 +1 @@ +#GET^http://localhost:8080/ diff --git a/test_api/test_api_nonexist_error.barb b/test_api/test_api_nonexist_error.barb new file mode 100644 index 0000000..9f95a60 --- /dev/null +++ b/test_api/test_api_nonexist_error.barb @@ -0,0 +1,2 @@ +#GET^http://localhost:60000/ + diff --git a/test_api/test_api_post.barb b/test_api/test_api_post.barb new file mode 100644 index 0000000..2f905b1 --- /dev/null +++ b/test_api/test_api_post.barb @@ -0,0 +1,3 @@ +#POST^http://localhost:8080/ + +{"value": 1234} |