Skip to content

Commit 9bc1d9c

Browse files
committed
tests: skip extensions cli test shouldn't call process file either
all other tests in this file assert on `process_file` being called with correct arguments. We need specific tests which test that the configuration is interpreted correctly
1 parent 7565a38 commit 9bc1d9c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

tests/test_cli.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path
2-
from typing import Iterable, List, Optional, Type
2+
from typing import Iterable, List, Optional, Tuple, Type
33
from unittest import mock
44

55
import pytest
@@ -13,6 +13,7 @@
1313
from unblob.processing import (
1414
DEFAULT_DEPTH,
1515
DEFAULT_PROCESS_NUM,
16+
DEFAULT_SKIP_EXTENSION,
1617
DEFAULT_SKIP_MAGIC,
1718
ExtractionConfig,
1819
)
@@ -310,16 +311,16 @@ def test_keep_extracted_chunks(
310311

311312

312313
@pytest.mark.parametrize(
313-
"skip_extension, extracted_files_count",
314+
"skip_extension, expected_skip_extensions",
314315
[
315-
pytest.param([], 5, id="skip-extension-empty"),
316-
pytest.param([""], 5, id="skip-zip-extension-empty-suffix"),
317-
pytest.param([".zip"], 0, id="skip-extension-zip"),
318-
pytest.param([".rlib"], 5, id="skip-extension-rlib"),
316+
pytest.param((), DEFAULT_SKIP_EXTENSION, id="skip-extension-empty"),
317+
pytest.param(("",), ("",), id="skip-zip-extension-empty-suffix"),
318+
pytest.param((".zip",), (".zip",), id="skip-extension-zip"),
319+
pytest.param((".rlib",), (".rlib",), id="skip-extension-rlib"),
319320
],
320321
)
321322
def test_skip_extension(
322-
skip_extension: List[str], extracted_files_count: int, tmp_path: Path
323+
skip_extension: List[str], expected_skip_extensions: Tuple[str, ...], tmp_path: Path
323324
):
324325
runner = CliRunner()
325326
in_path = (
@@ -335,8 +336,12 @@ def test_skip_extension(
335336
for suffix in skip_extension:
336337
args += ["--skip-extension", suffix]
337338
params = [*args, "--extract-dir", str(tmp_path), str(in_path)]
338-
result = runner.invoke(unblob.cli.cli, params)
339-
assert extracted_files_count == len(list(tmp_path.rglob("*")))
339+
process_file_mock = mock.MagicMock()
340+
with mock.patch.object(unblob.cli, "process_file", process_file_mock):
341+
result = runner.invoke(unblob.cli.cli, params)
342+
assert (
343+
process_file_mock.call_args.args[0].skip_extension == expected_skip_extensions
344+
)
340345
assert result.exit_code == 0
341346

342347

0 commit comments

Comments
 (0)