Fix unittest errors

Signed-off-by: Ozan Unsal <ounsal@redhat.com>

(cherry picked from commit aa0aae3d3e (centos_master))
This commit is contained in:
Ozan Unsal 2023-07-19 13:16:29 +03:00 committed by Stepan Oksanichenko
parent b625ccea06
commit ce45fdc39a
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B
13 changed files with 161 additions and 30 deletions

View File

@ -167,6 +167,20 @@ class IterableMock(mock.Mock):
return iter([]) 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): class DummyCompose(object):
def __init__(self, topdir, config): def __init__(self, topdir, config):
self.supported = True self.supported = True
@ -241,6 +255,8 @@ class DummyCompose(object):
self.cache_region = None self.cache_region = None
self.containers_metadata = {} self.containers_metadata = {}
self.load_old_compose_config = mock.Mock(return_value=None) self.load_old_compose_config = mock.Mock(return_value=None)
self.koji_downloader = DummyKojiDownloader()
self.koji_downloader.cache_dir = "/prefix"
def setup_optional(self): def setup_optional(self):
self.all_variants["Server-optional"] = MockVariant( self.all_variants["Server-optional"] = MockVariant(

View File

@ -1209,6 +1209,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"buildinstall_method": "lorax", "buildinstall_method": "lorax",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"runroot_weights": {"buildinstall": 123}, "runroot_weights": {"buildinstall": 123},
}, },
) )
@ -1308,6 +1309,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"lorax_use_koji_plugin": True, "lorax_use_koji_plugin": True,
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"runroot_weights": {"buildinstall": 123}, "runroot_weights": {"buildinstall": 123},
}, },
) )
@ -1412,6 +1414,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"buildinstall_method": "buildinstall", "buildinstall_method": "buildinstall",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -1500,6 +1503,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"buildinstall_method": "buildinstall", "buildinstall_method": "buildinstall",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"failable_deliverables": [("^.+$", {"*": ["buildinstall"]})], "failable_deliverables": [("^.+$", {"*": ["buildinstall"]})],
}, },
) )
@ -1542,6 +1546,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"buildinstall_method": "lorax", "buildinstall_method": "lorax",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"failable_deliverables": [("^.+$", {"*": ["buildinstall"]})], "failable_deliverables": [("^.+$", {"*": ["buildinstall"]})],
}, },
) )
@ -1591,6 +1596,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"buildinstall_method": "lorax", "buildinstall_method": "lorax",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"failable_deliverables": [("^.+$", {"*": ["buildinstall"]})], "failable_deliverables": [("^.+$", {"*": ["buildinstall"]})],
}, },
) )
@ -1663,6 +1669,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"buildinstall_method": "lorax", "buildinstall_method": "lorax",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"failable_deliverables": [("^.+$", {"*": ["buildinstall"]})], "failable_deliverables": [("^.+$", {"*": ["buildinstall"]})],
}, },
) )
@ -1701,6 +1708,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"buildinstall_method": "lorax", "buildinstall_method": "lorax",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"runroot_weights": {"buildinstall": 123}, "runroot_weights": {"buildinstall": 123},
"buildinstall_topdir": "/buildinstall_topdir", "buildinstall_topdir": "/buildinstall_topdir",
}, },
@ -1810,6 +1818,7 @@ class BuildinstallThreadTestCase(PungiTestCase):
"buildinstall_method": "lorax", "buildinstall_method": "lorax",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )

View File

@ -552,6 +552,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
"release_version": "1.0", "release_version": "1.0",
"runroot_tag": "f25-build", "runroot_tag": "f25-build",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
cmd = { cmd = {
@ -633,6 +634,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
"release_version": "1.0", "release_version": "1.0",
"runroot_tag": "f25-build", "runroot_tag": "f25-build",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"create_jigdo": False, "create_jigdo": False,
"runroot_weights": {"createiso": 123}, "runroot_weights": {"createiso": 123},
}, },
@ -717,6 +719,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
"buildinstall_method": "lorax", "buildinstall_method": "lorax",
"runroot_tag": "f25-build", "runroot_tag": "f25-build",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
cmd = { cmd = {
@ -807,6 +810,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
"release_version": "1.0", "release_version": "1.0",
"runroot_tag": "f25-build", "runroot_tag": "f25-build",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
cmd = { cmd = {
@ -839,6 +843,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
"release_version": "1.0", "release_version": "1.0",
"runroot_tag": "f25-build", "runroot_tag": "f25-build",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"failable_deliverables": [("^.*$", {"*": "iso"})], "failable_deliverables": [("^.*$", {"*": "iso"})],
}, },
) )
@ -881,6 +886,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
"release_version": "1.0", "release_version": "1.0",
"runroot_tag": "f25-build", "runroot_tag": "f25-build",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"failable_deliverables": [("^.*$", {"*": "iso"})], "failable_deliverables": [("^.*$", {"*": "iso"})],
}, },
) )

View File

@ -122,6 +122,7 @@ class ImageContainerThreadTest(helpers.PungiTestCase):
self.topdir, self.topdir,
{ {
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"translate_paths": [(self.topdir, "http://root")], "translate_paths": [(self.topdir, "http://root")],
}, },
) )

View File

@ -35,6 +35,7 @@ class TestImageBuildPhase(PungiTestCase):
{ {
"image_build": {"^Client|Server$": [original_image_conf]}, "image_build": {"^Client|Server$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -127,6 +128,7 @@ class TestImageBuildPhase(PungiTestCase):
"image_build_version": "Rawhide", "image_build_version": "Rawhide",
"image_build": {"^Server$": [original_image_conf]}, "image_build": {"^Server$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -188,6 +190,7 @@ class TestImageBuildPhase(PungiTestCase):
"image_build_target": "f24", "image_build_target": "f24",
"image_build": {"^Server$": [original_image_conf]}, "image_build": {"^Server$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -251,6 +254,7 @@ class TestImageBuildPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -286,6 +290,7 @@ class TestImageBuildPhase(PungiTestCase):
{ {
"image_build": {"^Server$": [original_image_conf]}, "image_build": {"^Server$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
compose.setup_optional() compose.setup_optional()
@ -353,6 +358,7 @@ class TestImageBuildPhase(PungiTestCase):
{ {
"image_build": {"^Server$": [original_image_conf]}, "image_build": {"^Server$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"translate_paths": [("/my", "http://example.com")], "translate_paths": [("/my", "http://example.com")],
}, },
) )
@ -419,6 +425,7 @@ class TestImageBuildPhase(PungiTestCase):
{ {
"image_build": {"^Server$": [original_image_conf]}, "image_build": {"^Server$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
compose.setup_optional() compose.setup_optional()
@ -491,6 +498,7 @@ class TestImageBuildPhase(PungiTestCase):
{ {
"image_build": {"^Server$": [original_image_conf]}, "image_build": {"^Server$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -559,6 +567,7 @@ class TestImageBuildPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -602,6 +611,7 @@ class TestImageBuildPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -645,6 +655,7 @@ class TestImageBuildPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -681,6 +692,7 @@ class TestImageBuildPhase(PungiTestCase):
{ {
"image_build": {"^Server-optional$": [original_image_conf]}, "image_build": {"^Server-optional$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
compose.setup_optional() compose.setup_optional()
@ -744,6 +756,7 @@ class TestImageBuildPhase(PungiTestCase):
{ {
"image_build": {"^Server$": [original_image_conf]}, "image_build": {"^Server$": [original_image_conf]},
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
compose.setup_optional() compose.setup_optional()
@ -943,7 +956,9 @@ class TestCreateImageBuildThread(PungiTestCase):
@mock.patch("pungi.phases.image_build.KojiWrapper") @mock.patch("pungi.phases.image_build.KojiWrapper")
@mock.patch("pungi.phases.image_build.Linker") @mock.patch("pungi.phases.image_build.Linker")
def test_process_handle_fail(self, Linker, KojiWrapper): 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() pool = mock.Mock()
cmd = { cmd = {
"image_conf": { "image_conf": {
@ -1000,7 +1015,9 @@ class TestCreateImageBuildThread(PungiTestCase):
@mock.patch("pungi.phases.image_build.KojiWrapper") @mock.patch("pungi.phases.image_build.KojiWrapper")
@mock.patch("pungi.phases.image_build.Linker") @mock.patch("pungi.phases.image_build.Linker")
def test_process_handle_exception(self, Linker, KojiWrapper): 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() pool = mock.Mock()
cmd = { cmd = {
"image_conf": { "image_conf": {
@ -1046,7 +1063,9 @@ class TestCreateImageBuildThread(PungiTestCase):
@mock.patch("pungi.phases.image_build.KojiWrapper") @mock.patch("pungi.phases.image_build.KojiWrapper")
@mock.patch("pungi.phases.image_build.Linker") @mock.patch("pungi.phases.image_build.Linker")
def test_process_handle_fail_only_one_optional(self, Linker, KojiWrapper): 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() pool = mock.Mock()
cmd = { cmd = {
"image_conf": { "image_conf": {

View File

@ -958,7 +958,9 @@ class TestCreateLiveImageThread(PungiTestCase):
@mock.patch("pungi.phases.live_images.run") @mock.patch("pungi.phases.live_images.run")
@mock.patch("pungi.phases.live_images.KojiWrapper") @mock.patch("pungi.phases.live_images.KojiWrapper")
def test_process_handles_fail(self, KojiWrapper, run, copy2): 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() pool = mock.Mock()
cmd = { cmd = {
"ks_file": "/path/to/ks_file", "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.run")
@mock.patch("pungi.phases.live_images.KojiWrapper") @mock.patch("pungi.phases.live_images.KojiWrapper")
def test_process_handles_exception(self, KojiWrapper, run, copy2): 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() pool = mock.Mock()
cmd = { cmd = {
"ks_file": "/path/to/ks_file", "ks_file": "/path/to/ks_file",

View File

@ -28,6 +28,7 @@ class TestLiveMediaPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -85,6 +86,7 @@ class TestLiveMediaPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -148,6 +150,7 @@ class TestLiveMediaPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -259,6 +262,7 @@ class TestLiveMediaPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -364,6 +368,7 @@ class TestLiveMediaPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
}, },
) )
@ -394,6 +399,7 @@ class TestLiveMediaPhase(PungiTestCase):
] ]
}, },
"koji_profile": "koji", "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.get_file_size")
@mock.patch("pungi.phases.livemedia_phase.KojiWrapper") @mock.patch("pungi.phases.livemedia_phase.KojiWrapper")
def test_handle_koji_fail(self, KojiWrapper, get_file_size, get_mtime): 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 = { config = {
"arches": ["amd64", "x86_64"], "arches": ["amd64", "x86_64"],
"ksfile": "file.ks", "ksfile": "file.ks",
@ -688,6 +696,7 @@ class TestLiveMediaThread(PungiTestCase):
self.topdir, self.topdir,
{ {
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"failable_deliverables": [("^.+$", {"*": ["live-media"]})], "failable_deliverables": [("^.+$", {"*": ["live-media"]})],
}, },
) )
@ -757,6 +766,7 @@ class TestLiveMediaThread(PungiTestCase):
self.topdir, self.topdir,
{ {
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"failable_deliverables": [("^.+$", {"*": ["live-media"]})], "failable_deliverables": [("^.+$", {"*": ["live-media"]})],
}, },
) )

View File

@ -171,6 +171,7 @@ class OSBSThreadTest(helpers.PungiTestCase):
self.topdir, self.topdir,
{ {
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"translate_paths": [(self.topdir, "http://root")], "translate_paths": [(self.topdir, "http://root")],
}, },
) )

View File

@ -239,6 +239,7 @@ class RunOSBuildThreadTest(helpers.PungiTestCase):
self.topdir, self.topdir,
{ {
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"translate_paths": [(self.topdir, "http://root")], "translate_paths": [(self.topdir, "http://root")],
}, },
) )

View File

@ -103,6 +103,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
"release_name": "Fedora", "release_name": "Fedora",
"release_version": "Rawhide", "release_version": "Rawhide",
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"image_volid_formats": ["{release_short}-{variant}-{arch}"], "image_volid_formats": ["{release_short}-{variant}-{arch}"],
"translate_paths": [(self.topdir + "/work", "http://example.com/work")], "translate_paths": [(self.topdir + "/work", "http://example.com/work")],

View File

@ -123,6 +123,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
self.topdir, self.topdir,
{ {
"koji_profile": "koji", "koji_profile": "koji",
"koji_cache": "/tmp",
"runroot_tag": "rrt", "runroot_tag": "rrt",
"translate_paths": [(self.topdir, "http://example.com")], "translate_paths": [(self.topdir, "http://example.com")],
}, },

View File

@ -133,6 +133,14 @@ class PkgsetCompareMixin(object):
self.assertEqual({}, actual) self.assertEqual({}, actual)
class DummySystem(object):
def __init__(self):
self.methods = ["_listapi", "Dummy", "getRPM", "getRPMChecksums"]
def listMethods(self):
return self.methods
@ddt.ddt @ddt.ddt
@mock.patch("pungi.phases.pkgset.pkgsets.ReaderPool", new=FakePool) @mock.patch("pungi.phases.pkgset.pkgsets.ReaderPool", new=FakePool)
@mock.patch("kobo.pkgset.FileCache", new=MockFileCache) @mock.patch("kobo.pkgset.FileCache", new=MockFileCache)
@ -158,9 +166,10 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
self.tagged_rpms = json.load(f) self.tagged_rpms = json.load(f)
self.path_info = MockPathInfo(self.topdir) self.path_info = MockPathInfo(self.topdir)
self.koji_downloader = helpers.FSKojiDownloader()
self.koji_wrapper = mock.Mock() self.koji_wrapper = mock.Mock()
self.koji_wrapper.koji_proxy.listTaggedRPMS.return_value = self.tagged_rpms 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 self.koji_wrapper.koji_module.pathinfo = self.path_info
def _touch_files(self, filenames): 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") result = pkgset.populate("f25")
@ -229,7 +240,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
) )
pkgset = package_set( 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") result = pkgset.populate("f25")
@ -259,7 +274,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
) )
pkgset = pkgsets.KojiPackageSet( 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") result = pkgset.populate("f25")
@ -288,7 +307,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
) )
pkgset = pkgsets.KojiPackageSet( 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") result = pkgset.populate("f25")
@ -310,7 +333,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
def test_can_not_find_signed_package(self): def test_can_not_find_signed_package(self):
pkgset = pkgsets.KojiPackageSet( 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: with self.assertRaises(RuntimeError) as ctx:
@ -349,6 +376,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
arches=["x86_64"], arches=["x86_64"],
signed_packages_retries=2, signed_packages_retries=2,
signed_packages_wait=5, signed_packages_wait=5,
downloader=self.koji_downloader,
) )
result = pkgset.populate("f25") result = pkgset.populate("f25")
@ -386,6 +414,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
["cafebabe"], ["cafebabe"],
arches=["x86_64"], arches=["x86_64"],
allow_invalid_sigkeys=True, allow_invalid_sigkeys=True,
downloader=self.koji_downloader,
) )
pkgset.populate("f25") pkgset.populate("f25")
@ -406,7 +435,11 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
def test_can_not_find_any_package(self): def test_can_not_find_any_package(self):
pkgset = pkgsets.KojiPackageSet( 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: with self.assertRaises(RuntimeError) as ctx:
@ -431,6 +464,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
arches=["x86_64"], arches=["x86_64"],
signed_packages_retries=2, signed_packages_retries=2,
signed_packages_wait=5, signed_packages_wait=5,
downloader=self.koji_downloader,
) )
with self.assertRaises(RuntimeError) as ctx: with self.assertRaises(RuntimeError) as ctx:
@ -471,6 +505,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
[None], [None],
packages=["bash"], packages=["bash"],
populate_only_packages=True, populate_only_packages=True,
downloader=self.koji_downloader,
) )
result = pkgset.populate("f25") result = pkgset.populate("f25")
@ -579,6 +614,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
[None], [None],
arches=["x86_64"], arches=["x86_64"],
cache_region=cache_region, cache_region=cache_region,
downloader=self.koji_downloader,
) )
# Try calling the populate twice, but expect just single listTaggedRPMs # Try calling the populate twice, but expect just single listTaggedRPMs
@ -622,6 +658,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
[None], [None],
arches=["x86_64"], arches=["x86_64"],
cache_region=cache_region, cache_region=cache_region,
downloader=self.koji_downloader,
) )
# Try calling the populate twice with different event id. It must not # 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 = 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") result = pkgset.populate("f25")

View File

@ -79,7 +79,8 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
def setUp(self): def setUp(self):
super(TestPopulateGlobalPkgset, self).setUp() super(TestPopulateGlobalPkgset, self).setUp()
self.compose = helpers.DummyCompose( 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.koji_wrapper = mock.Mock()
self.pkgset_path = os.path.join( self.pkgset_path = os.path.join(
@ -98,7 +99,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
orig_pkgset = KojiPackageSet.return_value orig_pkgset = KojiPackageSet.return_value
pkgsets = source_koji.populate_global_pkgset( pkgsets = source_koji.populate_global_pkgset(
self.compose, self.koji_wrapper, "/prefix", 123456 self.compose, self.koji_wrapper, 123456
) )
self.assertEqual(len(pkgsets), 1) self.assertEqual(len(pkgsets), 1)
@ -117,7 +118,11 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
def test_populate_with_multiple_koji_tags(self, KojiPackageSet, materialize): def test_populate_with_multiple_koji_tags(self, KojiPackageSet, materialize):
self.compose = helpers.DummyCompose( self.compose = helpers.DummyCompose(
self.topdir, 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 materialize.side_effect = self.mock_materialize
@ -125,7 +130,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
KojiPackageSet.return_value.reuse = None KojiPackageSet.return_value.reuse = None
pkgsets = source_koji.populate_global_pkgset( pkgsets = source_koji.populate_global_pkgset(
self.compose, self.koji_wrapper, "/prefix", 123456 self.compose, self.koji_wrapper, 123456
) )
self.assertEqual(len(pkgsets), 2) self.assertEqual(len(pkgsets), 2)
@ -160,6 +165,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
{ {
"gather_method": "nodeps", "gather_method": "nodeps",
"pkgset_koji_tag": "f25", "pkgset_koji_tag": "f25",
"koji_cache": "/tmp",
"sigkeys": ["foo", "bar"], "sigkeys": ["foo", "bar"],
"additional_packages": [(".*", {"*": ["pkg", "foo.x86_64"]})], "additional_packages": [(".*", {"*": ["pkg", "foo.x86_64"]})],
}, },
@ -168,7 +174,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
materialize.side_effect = self.mock_materialize materialize.side_effect = self.mock_materialize
pkgsets = source_koji.populate_global_pkgset( pkgsets = source_koji.populate_global_pkgset(
self.compose, self.koji_wrapper, "/prefix", 123456 self.compose, self.koji_wrapper, 123456
) )
self.assertEqual(len(pkgsets), 1) self.assertEqual(len(pkgsets), 1)
six.assertCountEqual(self, pkgsets[0].packages, ["pkg", "foo"]) six.assertCountEqual(self, pkgsets[0].packages, ["pkg", "foo"])
@ -177,7 +183,9 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
class TestGetPackageSetFromKoji(helpers.PungiTestCase): class TestGetPackageSetFromKoji(helpers.PungiTestCase):
def setUp(self): def setUp(self):
super(TestGetPackageSetFromKoji, self).setUp() 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.compose.koji_event = None
self.koji_wrapper = mock.Mock() self.koji_wrapper = mock.Mock()
self.koji_wrapper.koji_proxy.getLastEvent.return_value = EVENT_INFO 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") @mock.patch("pungi.phases.pkgset.sources.source_koji.populate_global_pkgset")
def test_get_package_sets(self, pgp): def test_get_package_sets(self, pgp):
pkgsets = source_koji.get_pkgset_from_koji( pkgsets = source_koji.get_pkgset_from_koji(self.compose, self.koji_wrapper)
self.compose, self.koji_wrapper, "/prefix"
)
six.assertCountEqual( six.assertCountEqual(
self, self.koji_wrapper.koji_proxy.mock_calls, [mock.call.getLastEvent()] self, self.koji_wrapper.koji_proxy.mock_calls, [mock.call.getLastEvent()]
@ -196,7 +202,7 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase):
self.assertEqual( self.assertEqual(
pgp.call_args_list, 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): 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.phases.pkgset.sources.source_koji.get_pkgset_from_koji")
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper") @mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
def test_run(self, KojiWrapper, gpfk): 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" KojiWrapper.return_value.koji_module.config.topdir = "/prefix"
phase = source_koji.PkgsetSourceKoji(compose) phase = source_koji.PkgsetSourceKoji(compose)
pkgsets, path_prefix = phase() pkgsets, path_prefix = phase()
self.assertEqual(pkgsets, gpfk.return_value) self.assertEqual(pkgsets, gpfk.return_value)
self.assertEqual(path_prefix, "/prefix/") self.assertEqual(path_prefix, "/prefix")
self.assertEqual(KojiWrapper.mock_calls, [mock.call(compose)]) self.assertEqual(KojiWrapper.mock_calls, [mock.call(compose)])
@ -685,6 +693,7 @@ class TestAddModuleToVariant(helpers.PungiTestCase):
def setUp(self): def setUp(self):
super(TestAddModuleToVariant, self).setUp() super(TestAddModuleToVariant, self).setUp()
self.koji = mock.Mock() self.koji = mock.Mock()
self.compose = helpers.DummyCompose(self.topdir, {})
self.koji.koji_module.pathinfo.typedir.return_value = MMDS_DIR self.koji.koji_module.pathinfo.typedir.return_value = MMDS_DIR
files = ["modulemd.x86_64.txt", "modulemd.armv7hl.txt", "modulemd.txt"] files = ["modulemd.x86_64.txt", "modulemd.armv7hl.txt", "modulemd.txt"]
self.koji.koji_proxy.listArchives.return_value = [ self.koji.koji_proxy.listArchives.return_value = [
@ -707,7 +716,9 @@ class TestAddModuleToVariant(helpers.PungiTestCase):
def test_adding_module(self): def test_adding_module(self):
variant = mock.Mock(arches=["armhfp", "x86_64"], arch_mmds={}, modules=[]) 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"] mod1 = variant.arch_mmds["armhfp"]["module:master:20190318:abcdef"]
self.assertEqual(mod1.get_NSVCA(), "module:master:20190318:abcdef:armhfp") 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}], 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"] mod1 = variant.arch_mmds["armhfp"]["module:master:20190318:abcdef"]
self.assertEqual(mod1.get_NSVCA(), "module:master:20190318:abcdef:armhfp") 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=[]) variant = mock.Mock(arches=["armhfp", "x86_64"], arch_mmds={}, modules=[])
source_koji._add_module_to_variant( 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"] mod1 = variant.arch_mmds["armhfp"]["module:master:20190318:abcdef"]
@ -772,7 +789,11 @@ class TestAddModuleToVariant(helpers.PungiTestCase):
) )
source_koji._add_module_to_variant( 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"] mod1 = variant.arch_mmds["armhfp"]["module:master:20190318:abcdef"]