Skip to content

Commit 70bddb2

Browse files
feat: unit tests
Co-Authored-by: Nathan Python <nathan.python@hes-so.ch>
1 parent b72afc4 commit 70bddb2

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
from app import create_app
3+
4+
@pytest.fixture
5+
def client():
6+
"""Create a test client for the Flask application."""
7+
app = create_app()
8+
app.testing = True
9+
return app.test_client()

tests/test_app.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Test if the home page returns status code 200 and contains expected content"""
2+
def test_home_status_code(client):
3+
response = client.get("/")
4+
assert response.status_code == 200
5+
assert b"Hello" in response.data or b"Rero+" in response.data
6+
7+
""" Test if the help page returns status code 200 and contains expected content"""
8+
def test_help_status_code(client):
9+
response = client.get("/help")
10+
assert response.status_code == 200
11+
assert b"Aide" in response.data or b"Help" in response.data
12+
13+
""" Test if the 404 error handler returns status code 404 and contains expected content"""
14+
def test_404_status_code(client):
15+
response = client.get("/nonexistent_page")
16+
assert response.status_code == 404
17+
assert b"Page not found" in response.data

0 commit comments

Comments
 (0)