From 6e8970e6488e59285e46327af39f452d7c6bd3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 24 Feb 2016 19:32:46 +0100 Subject: [PATCH] [live-images] Fix crash when repo_from is not a list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lubomír Sedlář --- pungi/phases/live_images.py | 4 ++-- tests/test_liveimagesphase.py | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/pungi/phases/live_images.py b/pungi/phases/live_images.py index 87b21b73..e1b7d899 100644 --- a/pungi/phases/live_images.py +++ b/pungi/phases/live_images.py @@ -22,7 +22,7 @@ import pipes import shutil from kobo.threads import ThreadPool, WorkerThread -from kobo.shortcuts import run, save_to_file +from kobo.shortcuts import run, save_to_file, force_list from productmd.images import Image from pungi.wrappers.kojiwrapper import KojiWrapper @@ -106,7 +106,7 @@ class LiveImagesPhase(PhaseBase): # additional repos repos.extend(data.get("additional_repos", [])) - repos.extend(self._get_extra_repos(arch, variant, data.get('repo_from', []))) + repos.extend(self._get_extra_repos(arch, variant, force_list(data.get('repo_from', [])))) return repos def _get_release(self, image_conf): diff --git a/tests/test_liveimagesphase.py b/tests/test_liveimagesphase.py index ccbf6a3d..51185987 100755 --- a/tests/test_liveimagesphase.py +++ b/tests/test_liveimagesphase.py @@ -59,6 +59,49 @@ class TestLiveImagesPhase(PungiTestCase): compose.variants['Client'], 'amd64'))]) + @mock.patch('pungi.phases.live_images.ThreadPool') + def test_live_image_build_single_repo_from(self, ThreadPool): + compose = DummyCompose(self.topdir, { + 'live_images': [ + ('^Client$', { + 'amd64': { + 'kickstart': 'test.ks', + 'additional_repos': ['http://example.com/repo/'], + 'repo_from': 'Everything', + 'release': None, + } + }) + ], + }) + + phase = LiveImagesPhase(compose) + + phase.run() + + # assert at least one thread was started + self.assertTrue(phase.pool.add.called) + self.maxDiff = None + self.assertItemsEqual(phase.pool.queue_put.mock_calls, + [mock.call((compose, + {'ks_file': 'test.ks', + 'build_arch': 'amd64', + 'dest_dir': self.topdir + '/compose/Client/amd64/iso', + 'scratch': False, + 'repos': [self.topdir + '/compose/Client/amd64/os', + 'http://example.com/repo/', + self.topdir + '/compose/Everything/amd64/os'], + 'label': '', + 'name': None, + 'filename': 'image-name', + 'version': None, + 'specfile': None, + 'sign': False, + 'type': 'live', + 'release': '20151203.0', + 'ksurl': None}, + compose.variants['Client'], + 'amd64'))]) + @mock.patch('pungi.phases.live_images.ThreadPool') def test_live_image_build_without_rename(self, ThreadPool): compose = DummyCompose(self.topdir, {