Skip to content

Commit

Permalink
Using download-file with b2uri instead of deprecated commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kkalinowski-reef committed Dec 7, 2023
1 parent c777913 commit dbdefde
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions test/unit/test_console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ def test_download_by_name_1_thread(self):
def test_download_by_name_10_threads(self):
self._test_download_threads(download_by='name', num_threads=10)

def _test_download_to_directory(self, download_by):
def _test_download_to_directory(self, download_by: str):
self._authorize_account()
self._create_my_bucket()

Expand All @@ -1134,30 +1134,24 @@ def _test_download_to_directory(self, download_by):
remove_version=True,
)

b2uri = f'b2://my-bucket/{source_filename}' if download_by == 'name' else 'b2id://9999'
command = [
'download-file-by-%s' % download_by,
'download-file',
'--noProgress',
b2uri,
]
command += ['9999'] if download_by == 'id' else ['my-bucket', source_filename]

target_directory = os.path.join(temp_dir, 'target')
os.mkdir(target_directory)
command += [target_directory]
self._run_command(
command,
expected_stderr=
f'WARNING: download-file-by-{download_by} command is deprecated. Use download-file instead.\n'
)
self._run_command(command)
self.assertEqual(
local_file_content,
self._read_file(os.path.join(target_directory, source_filename))
)

# Download the file second time, to check the override behavior.
self._run_command(
command,
expected_stderr=
f'WARNING: download-file-by-{download_by} command is deprecated. Use download-file instead.\n'
)
self._run_command(command)
# We should get another file.
target_directory_files = [
elem
Expand Down

0 comments on commit dbdefde

Please sign in to comment.