-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch: apply health_check commit without the commit
- Loading branch information
1 parent
81a35ad
commit 11ad516
Showing
3 changed files
with
59 additions
and
0 deletions.
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
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,21 @@ | ||
class TestCheckHealth: | ||
def test_get(self, client): | ||
response = client.get("/check-health") | ||
assert response.status_code == 200 | ||
assert response.charset == "utf-8" | ||
assert response["Content-Type"] == "text/plain" | ||
assert response["Content-Length"] == "8" | ||
assert response.content.decode() == "Healthy\n" | ||
|
||
def test_get_as_clever(self, client): | ||
response = client.get( | ||
"/check-health", | ||
# CleverCloud probes connect directly through the IP, their HOST is not in the ALLOWED_HOSTS. | ||
HTTP_HOST="10.2.2.2", | ||
) | ||
assert response.status_code == 200 | ||
|
||
def test_get_with_error(self, client, mocker): | ||
mocker.patch("itou.www.middleware.connection.cursor", side_effect=Exception("Boom!")) | ||
response = client.get("/check-health") | ||
assert response.status_code == 500 |