32 lines
993 B
Python
32 lines
993 B
Python
# tests/conftest.py
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from logwatcher.config import FIXTURE_PATH
|
|
from logwatcher.logging import setup_logging
|
|
|
|
# original logs directory
|
|
ORIGINAL_LOGS_DIR = FIXTURE_PATH / "original_logs"
|
|
|
|
# define temp directory only for testing
|
|
os.environ["PYTEST_DEBUG_TEMPROOT"] = str(Path("output/test").absolute())
|
|
|
|
@pytest.fixture
|
|
def tmp_log_file(tmp_path):
|
|
return tmp_path / "logwatcher_test.log"
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def tmp_setup_logging(tmp_log_file):
|
|
"""Redirige les logs vers un dossier temporaire pendant les tests."""
|
|
setup_logging(file_path=tmp_log_file)
|
|
|
|
@pytest.fixture(name="original_log_files")
|
|
def original_log_files_fixture() -> tuple[Path, ...]:
|
|
"""
|
|
All real log files provided by N2 technicians.
|
|
Used for integration tests: these files contain both valid lines
|
|
and lines to be ignored (system logs, empty lines, directory headers).
|
|
"""
|
|
return tuple(ORIGINAL_LOGS_DIR.iterdir()) |