From a1c4bfb69375dda76799e99331c67330dbc96762 Mon Sep 17 00:00:00 2001 From: Henrik Corneliussen Date: Fri, 8 May 2026 19:05:56 +0200 Subject: [PATCH] Added automated test coverage --- .gitlab-ci.yml | 10 ++++------ requirements.txt | 2 ++ tests/test_app.py | 11 +++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 tests/test_app.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ba5ae7..6d291e7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,15 @@ stages: - - run + - test - build - deploy -run_flask_app: - stage: run +test: + stage: test image: python:3.11 before_script: - pip install -r requirements.txt script: - - python app.py & - - sleep 5 - - curl http://127.0.0.1:5000 + - PYTHONPATH=. pytest --cov=. --cov-report=term-missing build_docker_image: stage: build diff --git a/requirements.txt b/requirements.txt index f5f276f..a1a27b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,5 @@ Jinja2==3.1.6 MarkupSafe==3.0.3 Werkzeug==3.1.8 psycopg2-binary==2.9.11 +pytest==8.3.5 +pytest-cov==6.1.1 diff --git a/tests/test_app.py b/tests/test_app.py new file mode 100644 index 0000000..9babb87 --- /dev/null +++ b/tests/test_app.py @@ -0,0 +1,11 @@ +from app import app + +def test_basic(): + assert True + +def test_homepage(): + client = app.test_client() + + response = client.get("/") + + assert response.status_code == 200