From b01a2f9b640389e532cdc0ff81e9713dfd6f50db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lipovsk=C3=BD?= Date: Wed, 6 Nov 2024 14:21:46 +0100 Subject: [PATCH] Fixing unittests on python 3.12 [CLOUDDST-24653] --- .../test_tasks/test_build_merge_index_image.py | 12 ++++-------- tests/test_workers/test_tasks/test_fbc_utils.py | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/test_workers/test_tasks/test_build_merge_index_image.py b/tests/test_workers/test_tasks/test_build_merge_index_image.py index 426cbc57..f3b71588 100644 --- a/tests/test_workers/test_tasks/test_build_merge_index_image.py +++ b/tests/test_workers/test_tasks/test_build_merge_index_image.py @@ -25,7 +25,6 @@ @mock.patch('iib.workers.tasks.build_merge_index_image.create_dockerfile') @mock.patch('iib.workers.tasks.build._get_index_database') @mock.patch('iib.workers.tasks.build_merge_index_image.opm_migrate') -@mock.patch('iib.workers.tasks.build_merge_index_image.opm_registry_add_fbc') @mock.patch('iib.workers.tasks.build_merge_index_image._push_image') @mock.patch('iib.workers.tasks.build_merge_index_image._build_image') @mock.patch('iib.workers.tasks.build_merge_index_image.deprecate_bundles_fbc') @@ -66,7 +65,6 @@ def test_handle_merge_request( mock_dep_b_fbc, mock_bi, mock_pi, - mock_oraf, mock_om, mock_gid, mock_ogd, @@ -135,8 +133,8 @@ def side_effect(*args, base_dir, **kwargs): binary_image_config=binary_image_config, ) - mock_om.called_once() - mock_oraf.called_once() + if target_fbc: + mock_om.assert_called_once() assert mock_cleanup.call_count == 2 mock_prfb.assert_called_once_with( @@ -193,7 +191,6 @@ def side_effect(*args, base_dir, **kwargs): @mock.patch('iib.workers.tasks.build_merge_index_image.create_dockerfile') @mock.patch('iib.workers.tasks.build._get_index_database') @mock.patch('iib.workers.tasks.build_merge_index_image.opm_migrate') -@mock.patch('iib.workers.tasks.build_merge_index_image.opm_registry_add_fbc') @mock.patch('iib.workers.tasks.build_merge_index_image._create_and_push_manifest_list') @mock.patch('iib.workers.tasks.build_merge_index_image._push_image') @mock.patch('iib.workers.tasks.build_merge_index_image._build_image') @@ -232,7 +229,6 @@ def test_handle_merge_request_no_deprecate( mock_bi, mock_pi, mock_capml, - mock_oraf, mock_om, mock_gid, mock_ogd, @@ -282,8 +278,8 @@ def test_handle_merge_request_no_deprecate( distribution_scope='stage', ) - mock_om.called_once() - mock_oraf.called_once() + if target_fbc: + mock_om.assert_called_once() assert mock_cleanup.call_count == 2 mock_prfb.assert_called_once_with( diff --git a/tests/test_workers/test_tasks/test_fbc_utils.py b/tests/test_workers/test_tasks/test_fbc_utils.py index 0194f0a0..24645b75 100644 --- a/tests/test_workers/test_tasks/test_fbc_utils.py +++ b/tests/test_workers/test_tasks/test_fbc_utils.py @@ -119,7 +119,7 @@ def test_merge_catalogs_dirs(mock_enforce_json, mock_rc, mock_opm, tmpdir): merge_catalogs_dirs(src_config=source_dir, dest_config=destination_dir) mock_enforce_json.assert_called_once_with(destination_dir) - mock_rc.called_once_with( + mock_rc.assert_called_once_with( [mock_opm.opm_version, 'validate', destination_dir], exc_msg=f'Failed to validate the content from config_dir {destination_dir}', ) @@ -157,7 +157,7 @@ def test_merge_catalogs_dirs_raise(mock_isdir, mock_cpt, tmpdir): with pytest.raises(IIBError, match=f"config directory does not exist: {source_dir}"): merge_catalogs_dirs(src_config=source_dir, dest_config=destination_dir) - mock_cpt.not_called() + mock_cpt.assert_not_called() def test_enforce_json_config_dir(tmpdir):