From 58253dcb7a170e71fbb228941dd0662ee0fe2c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Fri, 16 Feb 2024 14:47:57 +0100 Subject: [PATCH] Stop using Compress.compressed_filename --- kiwi/builder/install.py | 6 ++---- kiwi/tasks/result_bundle.py | 3 +-- test/unit/builder/install_test.py | 10 ++++------ test/unit/path_test.py | 2 +- test/unit/tasks/result_bundle_test.py | 8 ++++---- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/kiwi/builder/install.py b/kiwi/builder/install.py index 09b23190bf1..42215542205 100644 --- a/kiwi/builder/install.py +++ b/kiwi/builder/install.py @@ -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 diff --git a/kiwi/tasks/result_bundle.py b/kiwi/tasks/result_bundle.py index 7aa7cb157ef..ca1eec43246 100644 --- a/kiwi/tasks/result_bundle.py +++ b/kiwi/tasks/result_bundle.py @@ -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 diff --git a/test/unit/builder/install_test.py b/test/unit/builder/install_test.py index 69b5e50a709..748606a426f 100644 --- a/test/unit/builder/install_test.py +++ b/test/unit/builder/install_test.py @@ -342,6 +342,8 @@ 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() @@ -349,15 +351,11 @@ def test_create_install_pxe_archive( 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' diff --git a/test/unit/path_test.py b/test/unit/path_test.py index abe781dda42..ccc3b92202c 100644 --- a/test/unit/path_test.py +++ b/test/unit/path_test.py @@ -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' diff --git a/test/unit/tasks/result_bundle_test.py b/test/unit/tasks/result_bundle_test.py index b54a2e4ebd9..eb9317a3700 100644 --- a/test/unit/tasks/result_bundle_test.py +++ b/test/unit/tasks/result_bundle_test.py @@ -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 @@ -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( @@ -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 @@ -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