-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
32 lines (27 loc) · 1007 Bytes
/
Copy pathtest_app.py
File metadata and controls
32 lines (27 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pytest
from app import app, calculate_target_calories
@pytest.fixture
def client():
app.config['TESTING'] = True
app.secret_key = 'test_secret'
with app.test_client() as client:
yield client
def test_home_page(client):
"""Test that the landing page loads correctly."""
response = client.get('/')
assert response.status_code == 200
assert b"SmartFit" in response.data
def test_login_page_loads(client):
"""Test that login page loads."""
response = client.get('/login')
assert response.status_code == 200
assert b"Login" in response.data
def test_calorie_calculator():
"""Test the BMR logic independently."""
calories = calculate_target_calories(80, 180, 'MAINTAIN', 'MALE')
assert calories > 1500
assert isinstance(calories, int)
def test_dashboard_access_denied(client):
"""Ensure dashboard redirects if not logged in."""
response = client.get('/dashboard', follow_redirects=True)
assert b"Login" in response.data