This commit is contained in:
Ubuntu
2026-01-31 15:55:22 +00:00
parent 833eb21c79
commit 3c71d5da0a
6 changed files with 355 additions and 225 deletions

View File

@@ -1,20 +1,35 @@
"""Pytest configuration and fixtures."""
import os
import tempfile
from pathlib import Path
from typing import Generator
import pytest
from aegis_gitea_mcp.config import reset_settings
from aegis_gitea_mcp.audit import reset_audit_logger
from aegis_gitea_mcp.auth import reset_validator
from aegis_gitea_mcp.config import reset_settings
@pytest.fixture(autouse=True)
def reset_globals() -> Generator[None, None, None]:
"""Reset global singletons between tests."""
yield
def reset_globals(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Generator[None, None, None]:
"""Reset global singletons between tests and set up temp audit log."""
# Reset singletons before each test to ensure clean state
reset_settings()
reset_audit_logger()
reset_validator()
# Use temporary directory for audit logs in tests
audit_log_path = tmp_path / "audit.log"
monkeypatch.setenv("AUDIT_LOG_PATH", str(audit_log_path))
yield
# Also reset after test for cleanup
reset_settings()
reset_audit_logger()
reset_validator()
@pytest.fixture