Fix unittest errors

Signed-off-by: Ozan Unsal <ounsal@redhat.com>
This commit is contained in:
Ozan Unsal 2023-07-19 12:16:29 +02:00 committed by lsedlar
parent 77f8fa25ad
commit aa0aae3d3e
13 changed files with 161 additions and 30 deletions

View File

@ -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(

View File

@ -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",
},
)

View File

@ -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"})],
},
)

View File

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

View File

@ -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": {

View File

@ -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",

View File

@ -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"]})],
},
)

View File

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

View File

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

View File

@ -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")],

View File

@ -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")],
},

View File

@ -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")

View File

@ -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"]