From 4a4ef23e3c4e75d1e78ee3971bbdce853df4d409 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Feb 29 2016 07:23:26 +0000 Subject: [image-build] Fix resolving git urls After config was modified to work with sections, the resolving broke. This patch fixes it and adds a test to catch this problem in the future. Signed-off-by: Lubomír Sedlář --- diff --git a/pungi/phases/image_build.py b/pungi/phases/image_build.py index 8355727..cc50e37 100644 --- a/pungi/phases/image_build.py +++ b/pungi/phases/image_build.py @@ -100,7 +100,7 @@ class ImageBuildPhase(PhaseBase): continue # Replace possible ambiguous ref name with explicit hash. - if 'ksurl' in image_conf: + if 'ksurl' in image_conf['image-build']: image_conf["image-build"]['ksurl'] = resolve_git_url(image_conf["image-build"]['ksurl']) image_conf["image-build"]["variant"] = variant diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py index 8e03051..1ba2c9e 100755 --- a/tests/test_imagebuildphase.py +++ b/tests/test_imagebuildphase.py @@ -321,6 +321,45 @@ class TestImageBuildPhase(PungiTestCase): args, kwargs = phase.pool.queue_put.call_args self.assertTrue(args[0][1].get('scratch')) + @mock.patch('pungi.phases.image_build.resolve_git_url') + @mock.patch('pungi.phases.image_build.ThreadPool') + def test_image_build_resolve_ksurl(self, ThreadPool, resolve_git_url): + compose = DummyCompose(self.topdir, { + 'image_build': { + '^Server$': [ + { + 'image-build': { + 'format': [('docker', 'tar.xz')], + 'name': 'Fedora-Docker-Base', + 'target': 'f24', + 'version': 'Rawhide', + 'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git?#HEAD', + 'kickstart': "fedora-docker-base.ks", + 'distro': 'Fedora-20', + 'disk_size': 3, + 'arches': ['x86_64'], + 'scratch': True, + } + } + ] + }, + 'koji_profile': 'koji', + }) + + resolve_git_url.return_value = 'git://git.fedorahosted.org/git/spin-kickstarts.git?#BEEFCAFE' + + phase = ImageBuildPhase(compose) + + phase.run() + + # assert at least one thread was started + self.assertTrue(phase.pool.add.called) + + self.assertTrue(phase.pool.queue_put.called_once) + args, kwargs = phase.pool.queue_put.call_args + self.assertEqual(args[0][1]['image_conf'].get('image-build', {}).get('ksurl'), + resolve_git_url.return_value) + class TestCreateImageBuildThread(PungiTestCase):