mirror of
https://github.com/lintsinghua/DeepAudit.git
synced 2026-11-25 15:37:09 +08:00
Backend (951 tests): - Core security: JWT, password hashing, encryption - Agent core: state, config, validation, retry, circuit breaker, rate limiter, persistence, fallback, context, executor - API endpoints: tasks, projects, rules, prompts, auth deps - Services: json_parser, event_manager, stream_handler, tools, tokenizer, prompt_cache, report generator, scanner utils - Models, schemas, LLM factory/base adapter Frontend (331 tests, vitest + @testing-library/react): - API clients: serverClient, agentTasks, prompts, rules - Utilities: fetchWrapper, errorHandler, logger, projectUtils, zipStorage, performanceMonitor, utils - Hooks: useAsync, useDebounce, useLocalStorage - Config, services, AgentAudit utils - Test infra: vitest.config.ts, setup.ts, coverage-v8 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""
|
|
Shared test fixtures for all backend tests.
|
|
"""
|
|
|
|
import pytest
|
|
import tempfile
|
|
import shutil
|
|
from unittest.mock import patch, MagicMock
|
|
|
|
from app.core.config import Settings
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def mock_settings():
|
|
"""Patch settings with deterministic test values to avoid env dependency."""
|
|
test_settings = Settings(
|
|
SECRET_KEY="test_secret_key_for_testing_1234567890",
|
|
ALGORITHM="HS256",
|
|
ACCESS_TOKEN_EXPIRE_MINUTES=30,
|
|
)
|
|
with patch("app.core.config.settings", test_settings):
|
|
with patch("app.core.security.settings", test_settings):
|
|
with patch("app.core.encryption.settings", test_settings):
|
|
yield test_settings
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def reset_agent_config():
|
|
"""Clear @lru_cache on get_agent_config between tests to prevent state leakage."""
|
|
from app.services.agent.config import get_agent_config
|
|
|
|
get_agent_config.cache_clear()
|
|
yield
|
|
get_agent_config.cache_clear()
|
|
|
|
|
|
@pytest.fixture
|
|
def temp_dir():
|
|
"""Provide a clean temporary directory (cleaned up after test)."""
|
|
d = tempfile.mkdtemp(prefix="deepaudit_test_")
|
|
yield d
|
|
shutil.rmtree(d, ignore_errors=True)
|