Skip to content

Commit

Permalink
Named placeholder for format string in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kkalinowski-reef committed Dec 20, 2023
1 parent f392bc0 commit c2ef048
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 12 additions & 6 deletions test/unit/console_tool/test_download_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
EXPECTED_STDOUT_DOWNLOAD = '''
File name: file1.txt
File id: 9999
Output file path: {}
Output file path: {output_path}
File size: 11
Content type: b2/x-auto
Content sha1: 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
Expand All @@ -42,7 +42,7 @@ def test_download_file_by_uri__flag_support(b2_cli, uploaded_file, tmp_path, fla
b2_cli.run(
['download-file', flag, 'b2id://9999',
str(output_path)],
expected_stdout=expected_stdout.format(pathlib.Path(output_path).resolve())
expected_stdout=expected_stdout.format(output_path=pathlib.Path(output_path).resolve())
)
assert output_path.read_text() == uploaded_file['content']

Expand All @@ -56,7 +56,9 @@ def test_download_file_by_uri__b2_uri_support(b2_cli, uploaded_file, tmp_path, b

b2_cli.run(
['download-file', b2_uri, str(output_path)],
expected_stdout=EXPECTED_STDOUT_DOWNLOAD.format(pathlib.Path(output_path).resolve())
expected_stdout=EXPECTED_STDOUT_DOWNLOAD.format(
output_path=pathlib.Path(output_path).resolve()
)
)
assert output_path.read_text() == uploaded_file['content']

Expand All @@ -76,7 +78,9 @@ def test_download_file_by_name(b2_cli, local_file, uploaded_file, tmp_path, flag
'download-file-by-name', uploaded_file['bucket'], uploaded_file['fileName'],
str(output_path)
],
expected_stdout=EXPECTED_STDOUT_DOWNLOAD.format(pathlib.Path(output_path).resolve()),
expected_stdout=EXPECTED_STDOUT_DOWNLOAD.format(
output_path=pathlib.Path(output_path).resolve()
),
expected_stderr=
'WARNING: download-file-by-name command is deprecated. Use download-file instead.\n',
)
Expand All @@ -95,7 +99,7 @@ def test_download_file_by_id(b2_cli, uploaded_file, tmp_path, flag, expected_std

b2_cli.run(
['download-file-by-id', flag, '9999', str(output_path)],
expected_stdout=expected_stdout.format(pathlib.Path(output_path).resolve()),
expected_stdout=expected_stdout.format(output_path=pathlib.Path(output_path).resolve()),
expected_stderr=
'WARNING: download-file-by-id command is deprecated. Use download-file instead.\n',
)
Expand Down Expand Up @@ -123,7 +127,9 @@ def reader():
uploaded_file['fileName'],
str(output_path)
],
expected_stdout=EXPECTED_STDOUT_DOWNLOAD.format(pathlib.Path(output_path).resolve()),
expected_stdout=EXPECTED_STDOUT_DOWNLOAD.format(
output_path=pathlib.Path(output_path).resolve()
),
expected_stderr=
'WARNING: download-file-by-name command is deprecated. Use download-file instead.\n',
)
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ def test_files_encrypted(self):
expected_stdout_template = '''
File name: file1.txt
File id: 9999
Output file path: {}
Output file path: {output_path}
File size: 11
Content type: b2/x-auto
Content sha1: 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
Expand All @@ -988,7 +988,7 @@ def test_files_encrypted(self):
Download finished
'''
expected_stdout = expected_stdout_template.format(
pathlib.Path(local_download1).resolve()
output_path=pathlib.Path(local_download1).resolve()
)

self._run_command(
Expand All @@ -1001,7 +1001,7 @@ def test_files_encrypted(self):
# Download file by ID. (Same expected output as downloading by name)
local_download2 = os.path.join(temp_dir, 'download2.txt')
expected_stdout = expected_stdout_template.format(
pathlib.Path(local_download2).resolve()
output_path=pathlib.Path(local_download2).resolve()
)
self._run_command(
['download-file', '--noProgress', 'b2id://9999', local_download2], expected_stdout,
Expand Down

0 comments on commit c2ef048

Please sign in to comment.