Create tests/test_routes.py
Browse files123456789101112131415161718192021222324252627282930import pytestfrom flask import url_forfrom app import create_appfrom app.models import User, Ad
@pytest.fixturedef app(): app = create_app() app.config['TESTING'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:' with app.app_context(): db.create_all() yield app db.drop_all()
@pytest.fixturedef 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 authenticatedapp/tests/test_routes.pyAdded+30