"""Tests for routes.""" import pytest from app import create_app @pytest.fixture def client(): """Create a test client for the Flask application.""" app = create_app() app.config["TESTING"] = True with app.test_client() as client: yield client class TestMainRoutes: """Test cases for main routes.""" def test_index_route(self, client) -> None: """Test the index route.""" response = client.get("/api/") assert response.status_code == 200 assert response.get_json() == { "message": "API is running", "status": "ok", } def test_health_route(self, client) -> None: """Test health check route.""" response = client.get("/api/health") assert response.status_code == 200 assert response.get_json() == {"status": "ok"} def test_protected_route_without_auth(self, client) -> None: """Test protected route without authentication.""" response = client.get("/api/protected") assert response.status_code == 401 data = response.get_json() assert data["error"] == "Authentication required (JWT or API token)"