From aa0aae3d3e1aadc15b071ea3ae03d827fcc586dc Mon Sep 17 00:00:00 2001 From: Ozan Unsal Date: Wed, 19 Jul 2023 12:16:29 +0200 Subject: [PATCH] Fix unittest errors Signed-off-by: Ozan Unsal --- 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 6f3ace71..c56937b6 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 c2051f83..32224a84 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 f71a45c0..5cd21ad2 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 2bb99c7b..246bb267 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 6eb58133..f62aa3f9 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 acade8e6..af7327ad 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 9eea3374..c4161361 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 9a45dfea..5df69091 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 0b6637a2..c337b60e 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 de705754..1dcacd85 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 40c99076..44c623a1 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 793d8372..0c1256d7 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 + + @mock.patch("pungi.phases.pkgset.pkgsets.ReaderPool", new=FakePool) @mock.patch("kobo.pkgset.FileCache", new=MockFileCache) class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): @@ -142,9 +150,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): @@ -171,7 +180,9 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ] ) - pkgset = pkgsets.KojiPackageSet("pkgset", self.koji_wrapper, [None]) + pkgset = pkgsets.KojiPackageSet( + "pkgset", self.koji_wrapper, [None], downloader=self.koji_downloader + ) result = pkgset.populate("f25") @@ -205,7 +216,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ) pkgset = pkgsets.KojiPackageSet( - "pkgset", self.koji_wrapper, [None], arches=["x86_64"] + "pkgset", + self.koji_wrapper, + [None], + arches=["x86_64"], + downloader=self.koji_downloader, ) result = pkgset.populate("f25") @@ -235,7 +250,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") @@ -264,7 +283,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") @@ -286,7 +309,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: @@ -325,6 +352,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") @@ -362,6 +390,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ["cafebabe"], arches=["x86_64"], allow_invalid_sigkeys=True, + downloader=self.koji_downloader, ) pkgset.populate("f25") @@ -382,7 +411,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: @@ -407,6 +440,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: @@ -443,6 +477,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): [None], packages=["bash"], populate_only_packages=True, + downloader=self.koji_downloader, ) result = pkgset.populate("f25") @@ -543,6 +578,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 @@ -582,6 +618,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 @@ -635,7 +672,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): ] pkgset = pkgsets.KojiPackageSet( - "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 c4106808..6141652c 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -73,7 +73,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( @@ -92,7 +93,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) @@ -111,7 +112,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 @@ -119,7 +124,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) @@ -154,6 +159,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase): { "gather_method": "nodeps", "pkgset_koji_tag": "f25", + "koji_cache": "/tmp", "sigkeys": ["foo", "bar"], "additional_packages": [(".*", {"*": ["pkg", "foo.x86_64"]})], }, @@ -162,7 +168,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"]) @@ -171,7 +177,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 @@ -179,9 +187,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()] @@ -190,7 +196,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): @@ -440,14 +446,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)]) @@ -679,6 +687,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 = [ @@ -701,7 +710,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") @@ -723,7 +734,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") @@ -740,7 +753,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"] @@ -766,7 +783,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"]