Skip to content

Commit

Permalink
Stop using Compress.compressed_filename
Browse files Browse the repository at this point in the history
  • Loading branch information
dcermak committed Feb 16, 2024
1 parent fd28283 commit 58253dc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
6 changes: 2 additions & 4 deletions kiwi/builder/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,9 @@ def create_install_pxe_archive(self) -> None:
source_filename=self.diskname,
keep_source_on_compress=True
)
compress.xz(self.xz_options)
# set by compress.xz
assert compress.compressed_filename
xz_archive = compress.xz(self.xz_options)
Command.run(
['mv', compress.compressed_filename, pxe_image_filename]
['mv', xz_archive, pxe_image_filename]
)

# the system image transfer is checked against a checksum
Expand Down
3 changes: 1 addition & 2 deletions kiwi/tasks/result_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def process(self):
if result_file.compress:
log.info('--> XZ compressing')
compress = Compress(bundle_file)
compress.xz(self.runtime_config.get_xz_options())
bundle_file = compress.compressed_filename
bundle_file = compress.xz(self.runtime_config.get_xz_options())

if self.command_args['--zsync-source'] and result_file.shasum:
# Files with a checksum are considered to be image files
Expand Down
10 changes: 4 additions & 6 deletions test/unit/builder/install_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,22 +342,20 @@ def test_create_install_pxe_archive(
mock_md5.return_value = checksum

compress = mock.Mock()
src = 'target_dir/result-image.x86_64-1.2.3.raw'
compress.xz.return_value = src
mock_compress.return_value = compress

m_open = mock_open()
with patch('builtins.open', m_open, create=True):
self.install_image.create_install_pxe_archive()

mock_compress.assert_called_once_with(
keep_source_on_compress=True,
source_filename='target_dir/result-image.x86_64-1.2.3.raw'
keep_source_on_compress=True, source_filename=src
)
compress.xz.assert_called_once_with(None)
assert mock_command.call_args_list[0] == call(
[
'mv', compress.compressed_filename,
'tmpdir/result-image.x86_64-1.2.3.xz'
]
['mv', src, 'tmpdir/result-image.x86_64-1.2.3.xz']
)
mock_md5.assert_called_once_with(
'target_dir/result-image.x86_64-1.2.3.raw'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/path_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_which(self, mock_exists, mock_env, mock_access):
assert Path.which('some-file') is None
mock_env.return_value = None
mock_exists.return_value = True
assert Path.which('some-file', ['alternative']) == \
assert Path.which('some-file', alternative_lookup_paths=['alternative']) == \
'alternative/some-file'
mock_access.return_value = False
mock_env.return_value = '/usr/local/bin:/usr/bin:/bin'
Expand Down
8 changes: 4 additions & 4 deletions test/unit/tasks/result_bundle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_process_result_bundle(
checksum = Mock()
compress = Mock()
mock_path_which.return_value = 'zsyncmake'
compress.compressed_filename = 'compressed_filename'
compress.xz.return_value = 'compressed_filename'
mock_compress.return_value = compress
mock_checksum.return_value = checksum
mock_exists.return_value = False
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_process_result_bundle(
os.sep.join([self.abs_bundle_dir, 'test-image-1.2.3-Build_42'])
)
mock_checksum.assert_called_once_with(
compress.compressed_filename
'compressed_filename'
)
checksum.sha256.assert_called_once_with()
m_open.return_value.write.assert_called_once_with(
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_process_result_bundle_as_rpm(
checksum = Mock()
compress = Mock()
mock_path_which.return_value = 'zsyncmake'
compress.compressed_filename = 'compressed_filename'
compress.xz.return_value = 'compressed_filename'
mock_compress.return_value = compress
mock_checksum.return_value = checksum
mock_exists.return_value = False
Expand Down Expand Up @@ -303,7 +303,7 @@ def test_process_result_bundle_zsyncmake_missing(
checksum = Mock()
compress = Mock()
mock_path_which.return_value = None
compress.compressed_filename = 'compressed_filename'
compress.xz.return_value = 'compressed_filename'
mock_compress.return_value = compress
mock_checksum.return_value = checksum
mock_exists.return_value = False
Expand Down

0 comments on commit 58253dc

Please sign in to comment.