refactor(tests): ✅ udpate tests
update tests by adding a test_utils module
This commit is contained in:
+19
-1
@@ -1,8 +1,10 @@
|
||||
# tests/conftest.py
|
||||
import os
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from exchangelib import Message
|
||||
|
||||
from logwatcher.config import FIXTURE_PATH
|
||||
from logwatcher.logging_config import setup_logging
|
||||
@@ -52,4 +54,20 @@ 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"
|
||||
return FIXTURE_PATH / "invalid_logs"
|
||||
|
||||
|
||||
@pytest.fixture(scope="package")
|
||||
def make_mock_account():
|
||||
"""A fake Account with a msg_folder_root returning a fake Logs folder."""
|
||||
|
||||
def _make_mock_account(
|
||||
messages: list[Message] | None = None, analyzed_folder: MagicMock | None = None
|
||||
):
|
||||
account = MagicMock()
|
||||
logs_folder = account.msg_folder_root.__truediv__.return_value
|
||||
logs_folder.all.return_value = messages or []
|
||||
logs_folder.glob.return_value = [analyzed_folder] if analyzed_folder else []
|
||||
return account
|
||||
|
||||
return _make_mock_account
|
||||
Reference in New Issue
Block a user