23afe3f185
add classifier on log entries, clean test functions and uniform fixtures in windows-1252 since all logs are encoded in windows-1252
55 lines
1.6 KiB
Python
55 lines
1.6 KiB
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 log directory
|
|
ORIGINAL_LOG_DIR = FIXTURE_PATH / "original_logs"
|
|
|
|
# valid log directory
|
|
VALID_LOG_DIR = FIXTURE_PATH / "valid_logs"
|
|
|
|
# invalid_log_directory
|
|
INVALID_LOG_DIR = FIXTURE_PATH / "invalid_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_dir")
|
|
def original_log_dir_fixture() -> 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 FIXTURE_PATH / "original_logs"
|
|
|
|
@pytest.fixture(name="valid_log_dir")
|
|
def valid_log_dir_fixture() -> Path:
|
|
"""
|
|
All valid log files provided by N2 technicians.
|
|
Used for integration tests: these files contain both relevant and irrelevant logs
|
|
for N2 technicians.
|
|
"""
|
|
return FIXTURE_PATH / "valid_logs"
|
|
|
|
@pytest.fixture(name="invalid_log_dir")
|
|
def invalid_log_dir_fixture() -> Path:
|
|
"""
|
|
All invalid log files created for testing only.
|
|
Used for integration tests of parsing.
|
|
"""
|
|
return FIXTURE_PATH / "invalid_logs" |