11from pathlib import Path
2- from typing import List , Optional
2+ from typing import List , Optional , Type
33from unittest import mock
44
55import pytest
1111from unblob .handlers import BUILTIN_HANDLERS
1212from unblob .models import DirectoryHandler , Glob , Handler , HexString , MultiFile
1313from unblob .processing import DEFAULT_DEPTH , DEFAULT_PROCESS_NUM , ExtractionConfig
14+ from unblob .ui import (
15+ NullProgressReporter ,
16+ ProgressReporter ,
17+ RichConsoleProgressReporter ,
18+ )
1419
1520
1621class TestHandler (Handler ):
@@ -174,18 +179,50 @@ def test_dir_for_file(tmp_path: Path):
174179
175180
176181@pytest .mark .parametrize (
177- "params, expected_depth, expected_entropy_depth, expected_process_num, expected_verbosity" ,
182+ "params, expected_depth, expected_entropy_depth, expected_process_num, expected_verbosity, expected_progress_reporter " ,
178183 [
179- pytest .param ([], DEFAULT_DEPTH , 1 , DEFAULT_PROCESS_NUM , 0 , id = "empty" ),
180184 pytest .param (
181- ["--verbose" ], DEFAULT_DEPTH , 1 , DEFAULT_PROCESS_NUM , 1 , id = "verbose-1"
185+ [],
186+ DEFAULT_DEPTH ,
187+ 1 ,
188+ DEFAULT_PROCESS_NUM ,
189+ 0 ,
190+ RichConsoleProgressReporter ,
191+ id = "empty" ,
192+ ),
193+ pytest .param (
194+ ["--verbose" ],
195+ DEFAULT_DEPTH ,
196+ 1 ,
197+ DEFAULT_PROCESS_NUM ,
198+ 1 ,
199+ NullProgressReporter ,
200+ id = "verbose-1" ,
201+ ),
202+ pytest .param (
203+ ["-vv" ],
204+ DEFAULT_DEPTH ,
205+ 1 ,
206+ DEFAULT_PROCESS_NUM ,
207+ 2 ,
208+ NullProgressReporter ,
209+ id = "verbose-2" ,
210+ ),
211+ pytest .param (
212+ ["-vvv" ],
213+ DEFAULT_DEPTH ,
214+ 1 ,
215+ DEFAULT_PROCESS_NUM ,
216+ 3 ,
217+ NullProgressReporter ,
218+ id = "verbose-3" ,
219+ ),
220+ pytest .param (
221+ ["--depth" , "2" ], 2 , 1 , DEFAULT_PROCESS_NUM , 0 , mock .ANY , id = "depth"
182222 ),
183- pytest .param (["-vv" ], DEFAULT_DEPTH , 1 , DEFAULT_PROCESS_NUM , 2 , id = "verbose-2" ),
184223 pytest .param (
185- ["-vvv" ], DEFAULT_DEPTH , 1 , DEFAULT_PROCESS_NUM , 3 , id = "verbose-3 "
224+ ["--process-num" , "2" ], DEFAULT_DEPTH , 1 , 2 , 0 , mock . ANY , id = "process-num "
186225 ),
187- pytest .param (["--depth" , "2" ], 2 , 1 , DEFAULT_PROCESS_NUM , 0 , id = "depth" ),
188- pytest .param (["--process-num" , "2" ], DEFAULT_DEPTH , 1 , 2 , 0 , id = "process-num" ),
189226 ],
190227)
191228def test_archive_success (
@@ -194,6 +231,7 @@ def test_archive_success(
194231 expected_entropy_depth : int ,
195232 expected_process_num : int ,
196233 expected_verbosity : int ,
234+ expected_progress_reporter : Type [ProgressReporter ],
197235 tmp_path : Path ,
198236):
199237 runner = CliRunner ()
@@ -225,6 +263,7 @@ def test_archive_success(
225263 process_num = expected_process_num ,
226264 handlers = BUILTIN_HANDLERS ,
227265 verbose = expected_verbosity ,
266+ progress_reporter = expected_progress_reporter ,
228267 )
229268 process_file_mock .assert_called_once_with (config , in_path , None )
230269 logger_config_mock .assert_called_once_with (expected_verbosity , tmp_path , log_path )
0 commit comments