rastof9 commited on
Commit
4e032fa
·
verified ·
1 Parent(s): 4e6578b

Create tests/test_routes.py

Browse files
Files changed (1) hide show
  1. app/tests/test_routes.py +30 -0
app/tests/test_routes.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ from flask import url_for
3
+ from app import create_app
4
+ from app.models import User, Ad
5
+
6
+ @pytest.fixture
7
+ def app():
8
+ app = create_app()
9
+ app.config['TESTING'] = True
10
+ app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
11
+ with app.app_context():
12
+ db.create_all()
13
+ yield app
14
+ db.drop_all()
15
+
16
+ @pytest.fixture
17
+ def client(app):
18
+ return app.test_client()
19
+
20
+ def test_dashboard_route(client):
21
+ response = client.get(url_for('dashboard.index'))
22
+ assert response.status_code == 200
23
+
24
+ def test_login_route(client):
25
+ response = client.get(url_for('auth.login'))
26
+ assert response.status_code == 200
27
+
28
+ def test_compliance_report_route(client):
29
+ response = client.get(url_for('compliance.compliance_report'))
30
+ assert response.status_code == 302 # Redirects to login if not authenticated