-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves DST-232: added health check code for get response and logging test
- Loading branch information
Showing
3 changed files
with
49 additions
and
8 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
Empty file.
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,22 @@ | ||
import json | ||
import logging | ||
import pytest | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
from chatbot_api import app | ||
|
||
|
||
@pytest.fixture(name="test_client") | ||
def fixture_test_client(): | ||
return TestClient(app) | ||
|
||
|
||
class TestAPI: | ||
def test_read_healthcheck(self, caplog, test_client): | ||
with caplog.at_level(logging.INFO, logger="chatbot.chatbot_api"): | ||
response = test_client.get("/healthcheck") | ||
response_data = json.loads(response.content) | ||
assert response.status_code == 200 | ||
assert response_data["status"] == "OK" | ||
assert "Healthy" in caplog.messages[1] |