From e2c89fd435b903844c827bc395c0ae50fafdf7ce Mon Sep 17 00:00:00 2001 From: machikoyasuda Date: Thu, 30 Sep 2021 15:19:46 -0700 Subject: [PATCH 1/3] config(Docker): add pytest, coverage to Dockerfile.dev --- Dockerfile.dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index b83ff3e7..c168ba3f 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -8,4 +8,4 @@ RUN apt-get update \ && apt-get install -qq --no-install-recommends curl git jq ssh \ && python -m pip install --upgrade pip -RUN pip install --no-cache-dir flake8 debugpy pre-commit +RUN pip install --no-cache-dir flake8 debugpy pre-commit coverage pytest From a029840ac9b8c1df4e2c277a3385e91407cef306 Mon Sep 17 00:00:00 2001 From: machikoyasuda Date: Thu, 30 Sep 2021 15:20:10 -0700 Subject: [PATCH 2/3] testing: WIP - configure pytest and test healthcheck --- tests/__init__.py | 0 tests/conftest.py | 12 ++++++++++++ tests/test_app.py | 3 +++ 3 files changed, 15 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/test_app.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..df1e985d --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,12 @@ +import pytest + +from app import app as flask_app + +@pytest.fixture +def app(): + yield app + +@pytest.fixture +def client(app): + """A test client for the app.""" + return app.test_client() diff --git a/tests/test_app.py b/tests/test_app.py new file mode 100644 index 00000000..3336d749 --- /dev/null +++ b/tests/test_app.py @@ -0,0 +1,3 @@ +def test_healthcheck(app, client): + response = client.get('/healthcheck') + assert response.status_code == 200 From 380c9c9915abaf147e0466ac2a075f448ccfe5b6 Mon Sep 17 00:00:00 2001 From: machikoyasuda Date: Thu, 30 Sep 2021 22:52:39 +0000 Subject: [PATCH 3/3] test(healthcheck): add test configuration and test healthcheck endpoint --- tests/conftest.py | 5 ++--- tests/test_app.py | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index df1e985d..1128a184 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,12 +1,11 @@ import pytest -from app import app as flask_app +from app import app as server @pytest.fixture def app(): - yield app + yield server @pytest.fixture def client(app): - """A test client for the app.""" return app.test_client() diff --git a/tests/test_app.py b/tests/test_app.py index 3336d749..b6c3d3c4 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,3 +1,4 @@ def test_healthcheck(app, client): response = client.get('/healthcheck') assert response.status_code == 200 + assert response.data == b"Healthy"