From ce45fdc39aab2b3f335ef3e262f8fdcb6df6da17 Mon Sep 17 00:00:00 2001 From: Ozan Unsal Date: Wed, 19 Jul 2023 13:16:29 +0300 Subject: [PATCH] Fix unittest errors Signed-off-by: Ozan Unsal (cherry picked from commit aa0aae3d3e1aadc15b071ea3ae03d827fcc586dc (centos_master)) --- tests/helpers.py | 16 ++++++++ tests/test_buildinstall.py | 9 +++++ tests/test_createiso_phase.py | 6 +++ tests/test_image_container_phase.py | 1 + tests/test_imagebuildphase.py | 25 ++++++++++-- tests/test_liveimagesphase.py | 8 +++- tests/test_livemediaphase.py | 12 +++++- tests/test_osbs_phase.py | 1 + tests/test_osbuild_phase.py | 1 + tests/test_ostree_installer_phase.py | 1 + tests/test_ostree_phase.py | 1 + tests/test_pkgset_pkgsets.py | 57 ++++++++++++++++++++++++---- tests/test_pkgset_source_koji.py | 53 ++++++++++++++++++-------- 13 files changed, 161 insertions(+), 30 deletions(-) diff --git a/tests/helpers.py b/tests/helpers.py index 200d933c..00035c8a 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -167,6 +167,20 @@ class IterableMock(mock.Mock): return iter([]) +class FSKojiDownloader(object): + """Mock for KojiDownloadProxy that checks provided path.""" + + def get_file(self, path, validator=None): + return path if os.path.isfile(path) else None + + +class DummyKojiDownloader(object): + """Mock for KojiDownloadProxy that always finds the file in original location.""" + + def get_file(self, path, validator=None): + return path + + class DummyCompose(object): def __init__(self, topdir, config): self.supported = True @@ -241,6 +255,8 @@ class DummyCompose(object): self.cache_region = None self.containers_metadata = {} self.load_old_compose_config = mock.Mock(return_value=None) + self.koji_downloader = DummyKojiDownloader() + self.koji_downloader.cache_dir = "/prefix" def setup_optional(self): self.all_variants["Server-optional"] = MockVariant( diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 7188b854..9205e93c 100644 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -1209,6 +1209,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "buildinstall_method": "lorax", "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", "runroot_weights": {"buildinstall": 123}, }, ) @@ -1308,6 +1309,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "lorax_use_koji_plugin": True, "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", "runroot_weights": {"buildinstall": 123}, }, ) @@ -1412,6 +1414,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "buildinstall_method": "buildinstall", "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -1500,6 +1503,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "buildinstall_method": "buildinstall", "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", "failable_deliverables": [("^.+$", {"*": ["buildinstall"]})], }, ) @@ -1542,6 +1546,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "buildinstall_method": "lorax", "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", "failable_deliverables": [("^.+$", {"*": ["buildinstall"]})], }, ) @@ -1591,6 +1596,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "buildinstall_method": "lorax", "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", "failable_deliverables": [("^.+$", {"*": ["buildinstall"]})], }, ) @@ -1663,6 +1669,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "buildinstall_method": "lorax", "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", "failable_deliverables": [("^.+$", {"*": ["buildinstall"]})], }, ) @@ -1701,6 +1708,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "buildinstall_method": "lorax", "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", "runroot_weights": {"buildinstall": 123}, "buildinstall_topdir": "/buildinstall_topdir", }, @@ -1810,6 +1818,7 @@ class BuildinstallThreadTestCase(PungiTestCase): "buildinstall_method": "lorax", "runroot_tag": "rrt", "koji_profile": "koji", + "koji_cache": "/tmp", }, ) diff --git a/tests/test_createiso_phase.py b/tests/test_createiso_phase.py index bc0a2baa..0acb5abf 100644 --- a/tests/test_createiso_phase.py +++ b/tests/test_createiso_phase.py @@ -552,6 +552,7 @@ class CreateisoThreadTest(helpers.PungiTestCase): "release_version": "1.0", "runroot_tag": "f25-build", "koji_profile": "koji", + "koji_cache": "/tmp", }, ) cmd = { @@ -633,6 +634,7 @@ class CreateisoThreadTest(helpers.PungiTestCase): "release_version": "1.0", "runroot_tag": "f25-build", "koji_profile": "koji", + "koji_cache": "/tmp", "create_jigdo": False, "runroot_weights": {"createiso": 123}, }, @@ -717,6 +719,7 @@ class CreateisoThreadTest(helpers.PungiTestCase): "buildinstall_method": "lorax", "runroot_tag": "f25-build", "koji_profile": "koji", + "koji_cache": "/tmp", }, ) cmd = { @@ -807,6 +810,7 @@ class CreateisoThreadTest(helpers.PungiTestCase): "release_version": "1.0", "runroot_tag": "f25-build", "koji_profile": "koji", + "koji_cache": "/tmp", }, ) cmd = { @@ -839,6 +843,7 @@ class CreateisoThreadTest(helpers.PungiTestCase): "release_version": "1.0", "runroot_tag": "f25-build", "koji_profile": "koji", + "koji_cache": "/tmp", "failable_deliverables": [("^.*$", {"*": "iso"})], }, ) @@ -881,6 +886,7 @@ class CreateisoThreadTest(helpers.PungiTestCase): "release_version": "1.0", "runroot_tag": "f25-build", "koji_profile": "koji", + "koji_cache": "/tmp", "failable_deliverables": [("^.*$", {"*": "iso"})], }, ) diff --git a/tests/test_image_container_phase.py b/tests/test_image_container_phase.py index c78c9561..36282c25 100644 --- a/tests/test_image_container_phase.py +++ b/tests/test_image_container_phase.py @@ -122,6 +122,7 @@ class ImageContainerThreadTest(helpers.PungiTestCase): self.topdir, { "koji_profile": "koji", + "koji_cache": "/tmp", "translate_paths": [(self.topdir, "http://root")], }, ) diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py index 05a65db7..2cf982da 100644 --- a/tests/test_imagebuildphase.py +++ b/tests/test_imagebuildphase.py @@ -35,6 +35,7 @@ class TestImageBuildPhase(PungiTestCase): { "image_build": {"^Client|Server$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -127,6 +128,7 @@ class TestImageBuildPhase(PungiTestCase): "image_build_version": "Rawhide", "image_build": {"^Server$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -188,6 +190,7 @@ class TestImageBuildPhase(PungiTestCase): "image_build_target": "f24", "image_build": {"^Server$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -251,6 +254,7 @@ class TestImageBuildPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -286,6 +290,7 @@ class TestImageBuildPhase(PungiTestCase): { "image_build": {"^Server$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) compose.setup_optional() @@ -353,6 +358,7 @@ class TestImageBuildPhase(PungiTestCase): { "image_build": {"^Server$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", "translate_paths": [("/my", "http://example.com")], }, ) @@ -419,6 +425,7 @@ class TestImageBuildPhase(PungiTestCase): { "image_build": {"^Server$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) compose.setup_optional() @@ -491,6 +498,7 @@ class TestImageBuildPhase(PungiTestCase): { "image_build": {"^Server$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -559,6 +567,7 @@ class TestImageBuildPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -602,6 +611,7 @@ class TestImageBuildPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -645,6 +655,7 @@ class TestImageBuildPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -681,6 +692,7 @@ class TestImageBuildPhase(PungiTestCase): { "image_build": {"^Server-optional$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) compose.setup_optional() @@ -744,6 +756,7 @@ class TestImageBuildPhase(PungiTestCase): { "image_build": {"^Server$": [original_image_conf]}, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) compose.setup_optional() @@ -943,7 +956,9 @@ class TestCreateImageBuildThread(PungiTestCase): @mock.patch("pungi.phases.image_build.KojiWrapper") @mock.patch("pungi.phases.image_build.Linker") def test_process_handle_fail(self, Linker, KojiWrapper): - compose = DummyCompose(self.topdir, {"koji_profile": "koji"}) + compose = DummyCompose( + self.topdir, {"koji_profile": "koji", "koji_cache": "/tmp"} + ) pool = mock.Mock() cmd = { "image_conf": { @@ -1000,7 +1015,9 @@ class TestCreateImageBuildThread(PungiTestCase): @mock.patch("pungi.phases.image_build.KojiWrapper") @mock.patch("pungi.phases.image_build.Linker") def test_process_handle_exception(self, Linker, KojiWrapper): - compose = DummyCompose(self.topdir, {"koji_profile": "koji"}) + compose = DummyCompose( + self.topdir, {"koji_profile": "koji", "koji_cache": "/tmp"} + ) pool = mock.Mock() cmd = { "image_conf": { @@ -1046,7 +1063,9 @@ class TestCreateImageBuildThread(PungiTestCase): @mock.patch("pungi.phases.image_build.KojiWrapper") @mock.patch("pungi.phases.image_build.Linker") def test_process_handle_fail_only_one_optional(self, Linker, KojiWrapper): - compose = DummyCompose(self.topdir, {"koji_profile": "koji"}) + compose = DummyCompose( + self.topdir, {"koji_profile": "koji", "koji_cache": "/tmp"} + ) pool = mock.Mock() cmd = { "image_conf": { diff --git a/tests/test_liveimagesphase.py b/tests/test_liveimagesphase.py index 7ef9e398..57f042c4 100644 --- a/tests/test_liveimagesphase.py +++ b/tests/test_liveimagesphase.py @@ -958,7 +958,9 @@ class TestCreateLiveImageThread(PungiTestCase): @mock.patch("pungi.phases.live_images.run") @mock.patch("pungi.phases.live_images.KojiWrapper") def test_process_handles_fail(self, KojiWrapper, run, copy2): - compose = DummyCompose(self.topdir, {"koji_profile": "koji"}) + compose = DummyCompose( + self.topdir, {"koji_profile": "koji", "koji_cache": "/tmp"} + ) pool = mock.Mock() cmd = { "ks_file": "/path/to/ks_file", @@ -1011,7 +1013,9 @@ class TestCreateLiveImageThread(PungiTestCase): @mock.patch("pungi.phases.live_images.run") @mock.patch("pungi.phases.live_images.KojiWrapper") def test_process_handles_exception(self, KojiWrapper, run, copy2): - compose = DummyCompose(self.topdir, {"koji_profile": "koji"}) + compose = DummyCompose( + self.topdir, {"koji_profile": "koji", "koji_cache": "/tmp"} + ) pool = mock.Mock() cmd = { "ks_file": "/path/to/ks_file", diff --git a/tests/test_livemediaphase.py b/tests/test_livemediaphase.py index c286fad1..d2553788 100644 --- a/tests/test_livemediaphase.py +++ b/tests/test_livemediaphase.py @@ -28,6 +28,7 @@ class TestLiveMediaPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -85,6 +86,7 @@ class TestLiveMediaPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -148,6 +150,7 @@ class TestLiveMediaPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -259,6 +262,7 @@ class TestLiveMediaPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -364,6 +368,7 @@ class TestLiveMediaPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -394,6 +399,7 @@ class TestLiveMediaPhase(PungiTestCase): ] }, "koji_profile": "koji", + "koji_cache": "/tmp", }, ) @@ -611,7 +617,9 @@ class TestLiveMediaThread(PungiTestCase): @mock.patch("pungi.phases.livemedia_phase.get_file_size") @mock.patch("pungi.phases.livemedia_phase.KojiWrapper") def test_handle_koji_fail(self, KojiWrapper, get_file_size, get_mtime): - compose = DummyCompose(self.topdir, {"koji_profile": "koji"}) + compose = DummyCompose( + self.topdir, {"koji_profile": "koji", "koji_cache": "/tmp"} + ) config = { "arches": ["amd64", "x86_64"], "ksfile": "file.ks", @@ -688,6 +696,7 @@ class TestLiveMediaThread(PungiTestCase): self.topdir, { "koji_profile": "koji", + "koji_cache": "/tmp", "failable_deliverables": [("^.+$", {"*": ["live-media"]})], }, ) @@ -757,6 +766,7 @@ class TestLiveMediaThread(PungiTestCase): self.topdir, { "koji_profile": "koji", + "koji_cache": "/tmp", "failable_deliverables": [("^.+$", {"*": ["live-media"]})], }, ) diff --git a/tests/test_osbs_phase.py b/tests/test_osbs_phase.py index a44a15a6..d5c9febc 100644 --- a/tests/test_osbs_phase.py +++ b/tests/test_osbs_phase.py @@ -171,6 +171,7 @@ class OSBSThreadTest(helpers.PungiTestCase): self.topdir, { "koji_profile": "koji", + "koji_cache": "/tmp", "translate_paths": [(self.topdir, "http://root")], }, ) diff --git a/tests/test_osbuild_phase.py b/tests/test_osbuild_phase.py index 74f7b501..31ee6361 100644 --- a/tests/test_osbuild_phase.py +++ b/tests/test_osbuild_phase.py @@ -239,6 +239,7 @@ class RunOSBuildThreadTest(helpers.PungiTestCase): self.topdir, { "koji_profile": "koji", + "koji_cache": "/tmp", "translate_paths": [(self.topdir, "http://root")], }, ) diff --git a/tests/test_ostree_installer_phase.py b/tests/test_ostree_installer_phase.py index 58dc4dac..3d872345 100644 --- a/tests/test_ostree_installer_phase.py +++ b/tests/test_ostree_installer_phase.py @@ -103,6 +103,7 @@ class OstreeThreadTest(helpers.PungiTestCase): "release_name": "Fedora", "release_version": "Rawhide", "koji_profile": "koji", + "koji_cache": "/tmp", "runroot_tag": "rrt", "image_volid_formats": ["{release_short}-{variant}-{arch}"], "translate_paths": [(self.topdir + "/work", "http://example.com/work")], diff --git a/tests/test_ostree_phase.py b/tests/test_ostree_phase.py index 289d2715..ca061768 100644 --- a/tests/test_ostree_phase.py +++ b/tests/test_ostree_phase.py @@ -123,6 +123,7 @@ class OSTreeThreadTest(helpers.PungiTestCase): self.topdir, { "koji_profile": "koji", + "koji_cache": "/tmp", "runroot_tag": "rrt", "translate_paths": [(self.topdir, "http://example.com")], }, diff --git a/tests/test_pkgset_pkgsets.py b/tests/test_pkgset_pkgsets.py index abc57c77..5db88319 100644 --- a/tests/test_pkgset_pkgsets.py +++ b/tests/test_pkgset_pkgsets.py @@ -133,6 +133,14 @@ class PkgsetCompareMixin(object): self.assertEqual({}, actual) +class DummySystem(object): + def __init__(self): + self.methods = ["_listapi", "Dummy", "getRPM", "getRPMChecksums"] + + def listMethods(self): + return self.methods + + @ddt.ddt @mock.patch("pungi.phases.pkgset.pkgsets.ReaderPool", new=FakePool) @mock.patch("kobo.pkgset.FileCache", new=MockFileCache) @@ -158,9 +166,10 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): self.tagged_rpms = json.load(f) self.path_info = MockPathInfo(self.topdir) - + self.koji_downloader = helpers.FSKojiDownloader() self.koji_wrapper = mock.Mock() self.koji_wrapper.koji_proxy.listTaggedRPMS.return_value = self.tagged_rpms + self.koji_wrapper.koji_proxy.system = DummySystem() self.koji_wrapper.koji_module.pathinfo = self.path_info def _touch_files(self, filenames): @@ -191,7 +200,9 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ] ) - pkgset = package_set("pkgset", self.koji_wrapper, [None]) + pkgset = package_set( + "pkgset", self.koji_wrapper, [None], downloader=self.koji_downloader + ) result = pkgset.populate("f25") @@ -229,7 +240,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ) pkgset = package_set( - "pkgset", self.koji_wrapper, [None], arches=["x86_64"] + "pkgset", + self.koji_wrapper, + [None], + arches=["x86_64"], + downloader=self.koji_downloader, ) result = pkgset.populate("f25") @@ -259,7 +274,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ) pkgset = pkgsets.KojiPackageSet( - "pkgset", self.koji_wrapper, ["cafebabe", "deadbeef"], arches=["x86_64"] + "pkgset", + self.koji_wrapper, + ["cafebabe", "deadbeef"], + arches=["x86_64"], + downloader=self.koji_downloader, ) result = pkgset.populate("f25") @@ -288,7 +307,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ) pkgset = pkgsets.KojiPackageSet( - "pkgset", self.koji_wrapper, ["cafebabe", None], arches=["x86_64"] + "pkgset", + self.koji_wrapper, + ["cafebabe", None], + arches=["x86_64"], + downloader=self.koji_downloader, ) result = pkgset.populate("f25") @@ -310,7 +333,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): def test_can_not_find_signed_package(self): pkgset = pkgsets.KojiPackageSet( - "pkgset", self.koji_wrapper, ["cafebabe"], arches=["x86_64"] + "pkgset", + self.koji_wrapper, + ["cafebabe"], + arches=["x86_64"], + downloader=self.koji_downloader, ) with self.assertRaises(RuntimeError) as ctx: @@ -349,6 +376,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): arches=["x86_64"], signed_packages_retries=2, signed_packages_wait=5, + downloader=self.koji_downloader, ) result = pkgset.populate("f25") @@ -386,6 +414,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ["cafebabe"], arches=["x86_64"], allow_invalid_sigkeys=True, + downloader=self.koji_downloader, ) pkgset.populate("f25") @@ -406,7 +435,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): def test_can_not_find_any_package(self): pkgset = pkgsets.KojiPackageSet( - "pkgset", self.koji_wrapper, ["cafebabe", None], arches=["x86_64"] + "pkgset", + self.koji_wrapper, + ["cafebabe", None], + arches=["x86_64"], + downloader=self.koji_downloader, ) with self.assertRaises(RuntimeError) as ctx: @@ -431,6 +464,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): arches=["x86_64"], signed_packages_retries=2, signed_packages_wait=5, + downloader=self.koji_downloader, ) with self.assertRaises(RuntimeError) as ctx: @@ -471,6 +505,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): [None], packages=["bash"], populate_only_packages=True, + downloader=self.koji_downloader, ) result = pkgset.populate("f25") @@ -579,6 +614,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): [None], arches=["x86_64"], cache_region=cache_region, + downloader=self.koji_downloader, ) # Try calling the populate twice, but expect just single listTaggedRPMs @@ -622,6 +658,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): [None], arches=["x86_64"], cache_region=cache_region, + downloader=self.koji_downloader, ) # Try calling the populate twice with different event id. It must not @@ -679,7 +716,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ] pkgset = package_set( - "pkgset", self.koji_wrapper, [None], extra_builds=["pungi-4.1.3-3.fc25"] + "pkgset", + self.koji_wrapper, + [None], + extra_builds=["pungi-4.1.3-3.fc25"], + downloader=self.koji_downloader, ) result = pkgset.populate("f25") diff --git a/tests/test_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index da47fa86..2ea82363 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -79,7 +79,8 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase): def setUp(self): super(TestPopulateGlobalPkgset, self).setUp() self.compose = helpers.DummyCompose( - self.topdir, {"pkgset_koji_tag": "f25", "sigkeys": ["foo", "bar"]} + self.topdir, + {"pkgset_koji_tag": "f25", "sigkeys": ["foo", "bar"], "koji_cache": "/tmp"}, ) self.koji_wrapper = mock.Mock() self.pkgset_path = os.path.join( @@ -98,7 +99,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase): orig_pkgset = KojiPackageSet.return_value pkgsets = source_koji.populate_global_pkgset( - self.compose, self.koji_wrapper, "/prefix", 123456 + self.compose, self.koji_wrapper, 123456 ) self.assertEqual(len(pkgsets), 1) @@ -117,7 +118,11 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase): def test_populate_with_multiple_koji_tags(self, KojiPackageSet, materialize): self.compose = helpers.DummyCompose( self.topdir, - {"pkgset_koji_tag": ["f25", "f25-extra"], "sigkeys": ["foo", "bar"]}, + { + "pkgset_koji_tag": ["f25", "f25-extra"], + "sigkeys": ["foo", "bar"], + "koji_cache": "/tmp", + }, ) materialize.side_effect = self.mock_materialize @@ -125,7 +130,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase): KojiPackageSet.return_value.reuse = None pkgsets = source_koji.populate_global_pkgset( - self.compose, self.koji_wrapper, "/prefix", 123456 + self.compose, self.koji_wrapper, 123456 ) self.assertEqual(len(pkgsets), 2) @@ -160,6 +165,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase): { "gather_method": "nodeps", "pkgset_koji_tag": "f25", + "koji_cache": "/tmp", "sigkeys": ["foo", "bar"], "additional_packages": [(".*", {"*": ["pkg", "foo.x86_64"]})], }, @@ -168,7 +174,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase): materialize.side_effect = self.mock_materialize pkgsets = source_koji.populate_global_pkgset( - self.compose, self.koji_wrapper, "/prefix", 123456 + self.compose, self.koji_wrapper, 123456 ) self.assertEqual(len(pkgsets), 1) six.assertCountEqual(self, pkgsets[0].packages, ["pkg", "foo"]) @@ -177,7 +183,9 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase): class TestGetPackageSetFromKoji(helpers.PungiTestCase): def setUp(self): super(TestGetPackageSetFromKoji, self).setUp() - self.compose = helpers.DummyCompose(self.topdir, {"pkgset_koji_tag": "f25"}) + self.compose = helpers.DummyCompose( + self.topdir, {"pkgset_koji_tag": "f25", "koji_cache": "/tmp"} + ) self.compose.koji_event = None self.koji_wrapper = mock.Mock() self.koji_wrapper.koji_proxy.getLastEvent.return_value = EVENT_INFO @@ -185,9 +193,7 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase): @mock.patch("pungi.phases.pkgset.sources.source_koji.populate_global_pkgset") def test_get_package_sets(self, pgp): - pkgsets = source_koji.get_pkgset_from_koji( - self.compose, self.koji_wrapper, "/prefix" - ) + pkgsets = source_koji.get_pkgset_from_koji(self.compose, self.koji_wrapper) six.assertCountEqual( self, self.koji_wrapper.koji_proxy.mock_calls, [mock.call.getLastEvent()] @@ -196,7 +202,7 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase): self.assertEqual( pgp.call_args_list, - [mock.call(self.compose, self.koji_wrapper, "/prefix", EVENT_INFO)], + [mock.call(self.compose, self.koji_wrapper, EVENT_INFO)], ) def test_get_koji_modules(self): @@ -446,14 +452,16 @@ class TestSourceKoji(helpers.PungiTestCase): @mock.patch("pungi.phases.pkgset.sources.source_koji.get_pkgset_from_koji") @mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper") def test_run(self, KojiWrapper, gpfk): - compose = helpers.DummyCompose(self.topdir, {"koji_profile": "koji"}) + compose = helpers.DummyCompose( + self.topdir, {"koji_profile": "koji", "koji_cache": "/prefix"} + ) KojiWrapper.return_value.koji_module.config.topdir = "/prefix" phase = source_koji.PkgsetSourceKoji(compose) pkgsets, path_prefix = phase() self.assertEqual(pkgsets, gpfk.return_value) - self.assertEqual(path_prefix, "/prefix/") + self.assertEqual(path_prefix, "/prefix") self.assertEqual(KojiWrapper.mock_calls, [mock.call(compose)]) @@ -685,6 +693,7 @@ class TestAddModuleToVariant(helpers.PungiTestCase): def setUp(self): super(TestAddModuleToVariant, self).setUp() self.koji = mock.Mock() + self.compose = helpers.DummyCompose(self.topdir, {}) self.koji.koji_module.pathinfo.typedir.return_value = MMDS_DIR files = ["modulemd.x86_64.txt", "modulemd.armv7hl.txt", "modulemd.txt"] self.koji.koji_proxy.listArchives.return_value = [ @@ -707,7 +716,9 @@ class TestAddModuleToVariant(helpers.PungiTestCase): def test_adding_module(self): variant = mock.Mock(arches=["armhfp", "x86_64"], arch_mmds={}, modules=[]) - source_koji._add_module_to_variant(self.koji, variant, self.buildinfo) + source_koji._add_module_to_variant( + self.koji, variant, self.buildinfo, compose=self.compose + ) mod1 = variant.arch_mmds["armhfp"]["module:master:20190318:abcdef"] self.assertEqual(mod1.get_NSVCA(), "module:master:20190318:abcdef:armhfp") @@ -729,7 +740,9 @@ class TestAddModuleToVariant(helpers.PungiTestCase): modules=[{"name": "m1:latest-20190101:cafe", "glob": False}], ) - source_koji._add_module_to_variant(self.koji, variant, self.buildinfo) + source_koji._add_module_to_variant( + self.koji, variant, self.buildinfo, compose=self.compose + ) mod1 = variant.arch_mmds["armhfp"]["module:master:20190318:abcdef"] self.assertEqual(mod1.get_NSVCA(), "module:master:20190318:abcdef:armhfp") @@ -746,7 +759,11 @@ class TestAddModuleToVariant(helpers.PungiTestCase): variant = mock.Mock(arches=["armhfp", "x86_64"], arch_mmds={}, modules=[]) source_koji._add_module_to_variant( - self.koji, variant, self.buildinfo, add_to_variant_modules=True + self.koji, + variant, + self.buildinfo, + compose=self.compose, + add_to_variant_modules=True, ) mod1 = variant.arch_mmds["armhfp"]["module:master:20190318:abcdef"] @@ -772,7 +789,11 @@ class TestAddModuleToVariant(helpers.PungiTestCase): ) source_koji._add_module_to_variant( - self.koji, variant, self.buildinfo, add_to_variant_modules=True + self.koji, + variant, + self.buildinfo, + compose=self.compose, + add_to_variant_modules=True, ) mod1 = variant.arch_mmds["armhfp"]["module:master:20190318:abcdef"]