| import pytest | |
| from flask import url_for | |
| from app import create_app, db | |
| from app.models import User, Ad | |
| def app(): | |
| app = create_app() | |
| app.config.update({ | |
| 'TESTING': True, | |
| 'SQLALCHEMY_DATABASE_URI': 'sqlite:///:memory:', | |
| 'WTF_CSRF_ENABLED': False | |
| }) | |
| with app.app_context(): | |
| db.create_all() | |
| yield app | |
| db.drop_all() | |
| def client(app): | |
| return app.test_client() | |
| def test_dashboard_route(client): | |
| response = client.get(url_for('dashboard.index')) | |
| assert response.status_code == 200 | |
| def test_login_route(client): | |
| response = client.get(url_for('auth.login')) | |
| assert response.status_code == 200 | |
| def test_compliance_report_route(client): | |
| response = client.get(url_for('compliance.compliance_report')) | |
| assert response.status_code == 302 # Redirects to login if not authenticated |