diff --git a/pungi/compose.py b/pungi/compose.py index 74c2c11b..69511a84 100644 --- a/pungi/compose.py +++ b/pungi/compose.py @@ -340,3 +340,10 @@ class Compose(kobo.log.LoggingBase): self.failed_deliverables.setdefault(variant_uid, {}).setdefault(arch, []).append(deliverable) return True return False + + @property + def image_release(self): + """Generate a value to pass to Koji as image release. This includes + date, compose type and respin.""" + return '%s%s.%s' % (self.compose_date, self.ci_base.compose.type_suffix, + self.compose_respin) diff --git a/pungi/phases/image_build.py b/pungi/phases/image_build.py index badf53ef..ba6260ef 100644 --- a/pungi/phases/image_build.py +++ b/pungi/phases/image_build.py @@ -81,7 +81,7 @@ class ImageBuildPhase(PhaseBase): def _set_release(self, image_conf): """If release is set explicitly to None, replace it with date and respin.""" if 'release' in image_conf and image_conf['release'] is None: - image_conf['release'] = '%s.%s' % (self.compose.compose_date, self.compose.compose_respin) + image_conf['release'] = self.compose.image_release def run(self): for variant in self.compose.get_variants(): diff --git a/pungi/phases/live_images.py b/pungi/phases/live_images.py index d47462a6..789cd955 100644 --- a/pungi/phases/live_images.py +++ b/pungi/phases/live_images.py @@ -113,7 +113,7 @@ class LiveImagesPhase(PhaseBase): def _get_release(self, image_conf): """If release is set explicitly to None, replace it with date and respin.""" if 'release' in image_conf and image_conf['release'] is None: - return '%s.%s' % (self.compose.compose_date, self.compose.compose_respin) + return self.compose.image_release return image_conf.get('release', None) def run(self): diff --git a/pungi/phases/livemedia_phase.py b/pungi/phases/livemedia_phase.py index 087a893b..9756aed8 100644 --- a/pungi/phases/livemedia_phase.py +++ b/pungi/phases/livemedia_phase.py @@ -91,7 +91,7 @@ class LiveMediaPhase(PhaseBase): """ for key, conf in [('release', image_conf), ('live_media_release', self.compose.conf)]: if key in conf and conf[key] is None: - return '%s.%s' % (self.compose.compose_date, self.compose.compose_respin) + return self.compose.image_release return image_conf.get('release', self.compose.conf.get('live_media_release')) def _get_install_tree(self, image_conf, variant): diff --git a/tests/helpers.py b/tests/helpers.py index cf4dbd38..3c701e67 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -26,6 +26,7 @@ class DummyCompose(object): self.compose_respin = 0 self.compose_id = 'Test-20151203.0.t' self.compose_label = None + self.image_release = '20151203.t.0' self.ci_base = mock.Mock( release_id='Test-1.0', release=mock.Mock( diff --git a/tests/test_compose.py b/tests/test_compose.py index e2c2b76e..0f7457f8 100755 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -99,6 +99,30 @@ class ComposeTestCase(unittest.TestCase): 'RC-1.0', '1', 'rel_short', '2', '.iso', 'nightly', '.n', 'Server', '3.0'])) + @mock.patch('pungi.compose.ComposeInfo') + def test_image_release(self, ci): + conf = {} + ci.return_value.compose.respin = 2 + ci.return_value.compose.date = '20160107' + ci.return_value.compose.type = 'nightly' + ci.return_value.compose.type_suffix = '.n' + + compose = Compose(conf, self.tmp_dir) + + self.assertEqual(compose.image_release, '20160107.n.2') + + @mock.patch('pungi.compose.ComposeInfo') + def test_image_release_production(self, ci): + conf = {} + ci.return_value.compose.respin = 2 + ci.return_value.compose.date = '20160107' + ci.return_value.compose.type = 'production' + ci.return_value.compose.type_suffix = '.n' + + compose = Compose(conf, self.tmp_dir) + + self.assertEqual(compose.image_release, '20160107.n.2') + class StatusTest(unittest.TestCase): def setUp(self): diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py index 1ba2c9e4..e9a08541 100755 --- a/tests/test_imagebuildphase.py +++ b/tests/test_imagebuildphase.py @@ -284,7 +284,7 @@ class TestImageBuildPhase(PungiTestCase): self.assertTrue(phase.pool.queue_put.called_once) args, kwargs = phase.pool.queue_put.call_args self.assertEqual(args[0][1].get('image_conf', {}).get('image-build', {}).get('release'), - '20151203.0') + '20151203.t.0') @mock.patch('pungi.phases.image_build.ThreadPool') def test_image_build_scratch_build(self, ThreadPool): diff --git a/tests/test_liveimagesphase.py b/tests/test_liveimagesphase.py index dc575285..2b0a6664 100755 --- a/tests/test_liveimagesphase.py +++ b/tests/test_liveimagesphase.py @@ -54,7 +54,7 @@ class TestLiveImagesPhase(PungiTestCase): 'specfile': None, 'sign': False, 'type': 'live', - 'release': '20151203.0', + 'release': '20151203.t.0', 'subvariant': 'Client', 'ksurl': None}, compose.variants['Client'], @@ -102,7 +102,7 @@ class TestLiveImagesPhase(PungiTestCase): 'specfile': None, 'sign': False, 'type': 'live', - 'release': '20151203.0', + 'release': '20151203.t.0', 'subvariant': 'Client', 'ksurl': None}, compose.variants['Client'], @@ -147,7 +147,7 @@ class TestLiveImagesPhase(PungiTestCase): 'specfile': None, 'sign': False, 'type': 'live', - 'release': '20151203.0', + 'release': '20151203.t.0', 'subvariant': 'Client', 'ksurl': None}, compose.variants['Client'], @@ -309,7 +309,7 @@ class TestLiveImagesPhase(PungiTestCase): 'specfile': None, 'sign': False, 'type': 'live', - 'release': '20151203.0', + 'release': '20151203.t.0', 'subvariant': 'Client', 'ksurl': None}, compose.variants['Client'], diff --git a/tests/test_livemediaphase.py b/tests/test_livemediaphase.py index 7983068d..19d5cdb5 100755 --- a/tests/test_livemediaphase.py +++ b/tests/test_livemediaphase.py @@ -259,7 +259,7 @@ class TestLiveMediaPhase(PungiTestCase): 'ksurl': 'resolved', 'ksversion': '24', 'name': 'Fedora Server Live', - 'release': '20151203.0', + 'release': '20151203.t.0', 'repo': ['http://example.com/extra_repo', self.topdir + '/compose/Everything/$basearch/os', self.topdir + '/compose/Server/$basearch/os'],