✨feat(project): add from-mails command
add `from-mails` command that connect to the mailbox using configurations in .env file, parse, classify and report all not analyzed files.
This commit is contained in:
+22
-6
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from logwatcher.classifier import classify_log_entries
|
||||
from logwatcher.config import DATETIME_FORMAT, FIXTURE_PATH
|
||||
from logwatcher.config import DATETIME_FORMAT, FIXTURE_PATH, SourceType
|
||||
from logwatcher.models import LogEntry
|
||||
from logwatcher.parser import parse_log_file
|
||||
from logwatcher.reporter import (
|
||||
@@ -160,7 +160,12 @@ def test_build_reports(
|
||||
"""The three reports are built with correct headers, counts, and section separation."""
|
||||
start_date, end_date = _get_period(get_all_log_entries[0] + get_all_log_entries[1])
|
||||
reports = build_reports(
|
||||
get_all_log_entries[0], get_all_log_entries[1], start_date, end_date, nb_files
|
||||
SourceType.FILE,
|
||||
get_all_log_entries[0],
|
||||
get_all_log_entries[1],
|
||||
start_date,
|
||||
end_date,
|
||||
nb_files,
|
||||
)
|
||||
|
||||
assert "all" in reports and "n2" in reports and "other" in reports
|
||||
@@ -201,7 +206,7 @@ def _test_write_log_report(
|
||||
"""Write the reports, then verify files exist and their content matches build_reports."""
|
||||
results_path = output_dir / "results"
|
||||
relevant, irrelevant = log_entries_tuple
|
||||
write_log_report(relevant, irrelevant, nb_files, results_path)
|
||||
write_log_report(SourceType.FILE, relevant, irrelevant, nb_files, results_path)
|
||||
# check if files were created
|
||||
all_file, n2_file, other_file = (
|
||||
(results_path / "all.log"),
|
||||
@@ -214,7 +219,9 @@ def _test_write_log_report(
|
||||
|
||||
# check content
|
||||
start_date, end_date = _get_period(relevant + irrelevant)
|
||||
reports = build_reports(relevant, irrelevant, start_date, end_date, nb_files)
|
||||
reports = build_reports(
|
||||
SourceType.FILE, relevant, irrelevant, start_date, end_date, nb_files
|
||||
)
|
||||
nb_errors = {
|
||||
"all": len(relevant + irrelevant),
|
||||
"n2": len(relevant),
|
||||
@@ -271,7 +278,11 @@ def test_write_log_report_all_logs(
|
||||
"""The full fixture writes three files whose content matches build_reports exactly."""
|
||||
results_path = tmp_path / "results"
|
||||
write_log_report(
|
||||
get_all_log_entries[0], get_all_log_entries[1], nb_files, results_path
|
||||
SourceType.FILE,
|
||||
get_all_log_entries[0],
|
||||
get_all_log_entries[1],
|
||||
nb_files,
|
||||
results_path,
|
||||
)
|
||||
|
||||
# check if files were created
|
||||
@@ -287,7 +298,12 @@ def test_write_log_report_all_logs(
|
||||
# check content
|
||||
start_date, end_date = _get_period(get_all_log_entries[0] + get_all_log_entries[1])
|
||||
reports = build_reports(
|
||||
get_all_log_entries[0], get_all_log_entries[1], start_date, end_date, nb_files
|
||||
SourceType.FILE,
|
||||
get_all_log_entries[0],
|
||||
get_all_log_entries[1],
|
||||
start_date,
|
||||
end_date,
|
||||
nb_files,
|
||||
)
|
||||
assert reports["all"] == all_file.read_text(encoding="windows-1252")
|
||||
assert reports["n2"] == n2_file.read_text(encoding="windows-1252")
|
||||
|
||||
Reference in New Issue
Block a user