style(project): 🎨 improve all docstrings and centralize mail variables in mail_utils

This commit is contained in:
2026-09-17 12:59:07 +02:00
parent 6909ee7acf
commit 5e43a0cbb8
17 changed files with 116 additions and 101 deletions
+37
View File
@@ -0,0 +1,37 @@
from unittest.mock import MagicMock
from logwatcher.mail_utils import get_or_create_folder
def test_get_or_create_analyzed_folder_exists(make_mock_account, monkeypatch):
"""Returns the existing 'Analyzed' folder without creating it.
Args:
make_mock_account: Fake account owning the Logs folder
monkeypatch: MonkeyPatch to generate test context
"""
existing_folder = MagicMock()
account = make_mock_account(analyzed_folder=existing_folder)
fake_folder_cls = MagicMock()
with monkeypatch.context() as m:
m.setattr("logwatcher.mail_utils.Folder", fake_folder_cls)
result = get_or_create_folder(account, "Analyzed")
assert result is existing_folder
fake_folder_cls.assert_not_called()
def test_get_or_create_analyzed_folder_creates(make_mock_account, monkeypatch):
"""Creates the 'Analyzed' folder when it doesn't exist."""
account = make_mock_account(analyzed_folder=None)
fake_folder_instance = MagicMock()
fake_folder_cls = MagicMock(return_value=fake_folder_instance)
with monkeypatch.context() as m:
m.setattr("logwatcher.mail_utils.Folder", fake_folder_cls)
result = get_or_create_folder(account, "Analyzed")
assert result is fake_folder_instance
fake_folder_instance.save.assert_called_once()