-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(error): properly handle the 404 errors (#43)
Signed-off-by: Nicolas Crocfer <nicolas.crocfer@corp.ovh.com>
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>404 Not Found</title> | ||
</head> | ||
<body>%% error %%</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
def test_view(client): | ||
resp = client.get("/") | ||
assert resp.status_code == 200 | ||
assert not resp.is_json | ||
assert resp.mimetype == "text/html" | ||
assert "<title>Celery Director</title>" in str(resp.data) | ||
|
||
|
||
def test_404_view(client): | ||
resp = client.get("/notfound") | ||
assert resp.status_code == 404 | ||
assert not resp.is_json | ||
assert resp.mimetype == "text/html" | ||
assert "<title>404 Not Found</title>" in str(resp.data) | ||
|
||
|
||
def test_api(client): | ||
resp = client.get("/api/ping") | ||
assert resp.status_code == 200 | ||
assert resp.is_json | ||
assert resp.mimetype == "application/json" | ||
assert resp.json == {"message": "pong"} | ||
|
||
|
||
def test_404_api(client): | ||
resp = client.get("/api/notfound") | ||
assert resp.status_code == 404 | ||
assert resp.is_json | ||
assert resp.mimetype == "application/json" | ||
assert "404 Not Found" in resp.json["error"] |