✨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:
+18
-9
@@ -40,7 +40,7 @@ def get_argument_from_files(log_dir: Path, output_path: Path) -> list[str]:
|
||||
str(file) for file in log_dir.iterdir() if file.suffix in ("", ".txt", ".log")
|
||||
]
|
||||
|
||||
arguments = ["--output-dir", str(output_path)]
|
||||
arguments = ["from-files", "--output-dir", str(output_path)]
|
||||
for file in files:
|
||||
arguments += ["--input-files", file]
|
||||
return arguments
|
||||
@@ -55,11 +55,10 @@ def test_cli_help():
|
||||
"""
|
||||
results = runner.invoke(app, ["--help"])
|
||||
assert results.exit_code == 0
|
||||
assert "Usage: cli [OPTIONS]" in results.output
|
||||
assert "--input-dir" in results.output
|
||||
assert "--input-files" in results.output
|
||||
assert "--output-dir" in results.output
|
||||
assert "--verbose" in results.output
|
||||
assert "--version" in results.output
|
||||
assert "from-mail" in results.output
|
||||
assert "from-files" in results.output
|
||||
|
||||
|
||||
def test_version_cli():
|
||||
@@ -162,6 +161,7 @@ def test_cli_input_files_and_input_dir(output_path: Path):
|
||||
results = runner.invoke(
|
||||
app,
|
||||
[
|
||||
"from-files",
|
||||
"--input-files",
|
||||
"a.log",
|
||||
"--input-dir",
|
||||
@@ -183,7 +183,7 @@ def test_cli_neither_input_files_nor_input_dir():
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
results = runner.invoke(app)
|
||||
results = runner.invoke(app, ["from-files"])
|
||||
assert results.exit_code == 2
|
||||
assert "Either input_files or input_dir must be provided" in results.output
|
||||
|
||||
@@ -205,7 +205,7 @@ def test_cli_bad_input_file(tmp_path: Path, output_path: Path, invalid_log_dir:
|
||||
directory = str(tmp_path)
|
||||
results = runner.invoke(
|
||||
app,
|
||||
["--input-files", directory, "--output-dir", str(output_path)],
|
||||
["from-files", "--input-files", directory, "--output-dir", str(output_path)],
|
||||
)
|
||||
assert results.exit_code == 1
|
||||
assert isinstance(results.exception, ValueError)
|
||||
@@ -231,7 +231,7 @@ def test_cli_empty_input_files(output_path: Path, invalid_log_dir: Path):
|
||||
empty_file = str(next(invalid_log_dir.glob("empty_file.txt")))
|
||||
results = runner.invoke(
|
||||
app,
|
||||
["--input-files", empty_file, "--output-dir", str(output_path)],
|
||||
["from-files", "--input-files", empty_file, "--output-dir", str(output_path)],
|
||||
)
|
||||
assert results.exit_code == 0
|
||||
# check files
|
||||
@@ -288,6 +288,7 @@ def test_cli_input_files_or_input_dir(
|
||||
result = runner.invoke(
|
||||
app,
|
||||
[
|
||||
"from-files",
|
||||
"--input-dir",
|
||||
str(original_log_dir),
|
||||
"--output-dir",
|
||||
@@ -310,7 +311,14 @@ def test_cli_input_files_or_input_dir(
|
||||
def test_cli_input_files_one_file(valid_log_dir: Path, output_path: Path):
|
||||
mixed_logs_file = valid_log_dir / "mixed_logs.txt"
|
||||
result = runner.invoke(
|
||||
app, ["--input-files", str(mixed_logs_file), "--output-dir", str(output_path)]
|
||||
app,
|
||||
[
|
||||
"from-files",
|
||||
"--input-files",
|
||||
str(mixed_logs_file),
|
||||
"--output-dir",
|
||||
str(output_path),
|
||||
],
|
||||
)
|
||||
|
||||
assert result.exit_code == 0
|
||||
@@ -345,6 +353,7 @@ def test_cli_empty_input_directory(tmp_path: Path, output_path: Path):
|
||||
result = runner.invoke(
|
||||
app,
|
||||
[
|
||||
"from-files",
|
||||
"--input-dir",
|
||||
str(input_dir),
|
||||
"--output-dir",
|
||||
|
||||
Reference in New Issue
Block a user