import pytest from fastapi.testclient import TestClient from src.backend.main import app from src.backend.routers.audits.data import ROUTE from src.backend.users.manage import verify_auth0 ROUTE = f"/api{ROUTE}" # Dependency override to mock the Auth0 verifier, so that tests can run without # needing to authenticate with Auth0. Do it in form of auto-use fixture to always # have a fresh override for each test (thus avoiding issues when applying specific # overrides in specific tests). @pytest.fixture(autouse=True) def dependency_override(): app.dependency_overrides[verify_auth0] = lambda: {"mock_auth0": "credentials"} class TestAuditGroupsList: def test_audit_groups_list(self): """Test the endpoint that retrieves audit groups. As we're mocking the user's subject, the response should be empty, but the status code should be 200. """ with TestClient(app) as client: response = client.get(f"{ROUTE}/audit_groups") data = response.json()["data"] assert response.status_code == 200 assert isinstance(data["rows"], list) assert isinstance(data["total_row_count"], int)