def work(progress_update: ProgressUpdateCallable): unpack_iso( iso=iso, game_files_path=game_files_path, progress_update=progress_update, ) self.loaded_game_updated.emit()
def test_unpack_iso_success(mock_shared_process_code: MagicMock, ): # Setup iso = MagicMock() game_files_path = MagicMock() progress_update = MagicMock() # Run iso_packager.unpack_iso(iso, game_files_path, progress_update) # Assert game_files_path.mkdir.assert_called_once_with(parents=True, exist_ok=True) mock_shared_process_code.assert_called_once_with( target=iso_packager._disc_unpack_process, iso=iso, game_files_path=game_files_path, on_finish_message="Finished extracting ISO", progress_update=progress_update)
def test_unpack_iso_failure(mock_shared_process_code: MagicMock, ): # Setup iso = MagicMock() game_files_path = MagicMock() progress_update = MagicMock() exception_message = "Nah, don't wanna" game_files_path.mkdir.side_effect = OSError(exception_message) # Run with pytest.raises(RuntimeError) as exception: iso_packager.unpack_iso(iso, game_files_path, progress_update) # Assert game_files_path.mkdir.assert_called_once_with(parents=True, exist_ok=True) mock_shared_process_code.assert_not_called() assert str(exception.value) == "Unable to create files dir {}:\n{}".format( game_files_path, exception_message)
def unpack_iso(input_iso: Path, options: Options, progress_update: ProgressUpdateCallable, ): """ Unpacks the given ISO to the files listed in options :param input_iso: :param options: :param progress_update: :return: """ game_files_path = options.game_files_path delete_files_location(options) iso_packager.unpack_iso( iso=input_iso, game_files_path=game_files_path, progress_update=progress_update, )