From 8365cd0e1cde6684e0a5ffaeb938642008e7c897 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Jan 23 2019 06:55:29 +0000 Subject: The Lightblue.get_images_by_nvrs expects list as input, but we passed it str. This leads to an error that all ContainerImage objects were marked as unpublished and extra ODCS compose was requested for them even if not needed. --- diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py index 9d77583..4137825 100644 --- a/freshmaker/lightblue.py +++ b/freshmaker/lightblue.py @@ -501,9 +501,9 @@ class ContainerImage(dict): def resolve_published(self, lb_instance): # Get the published version of this image to find out if the image # was actually published. - image = lb_instance.get_images_by_nvrs( - self["brew"]["build"], published=True) - if image: + images = lb_instance.get_images_by_nvrs( + [self["brew"]["build"]], published=True) + if images: self["published"] = True else: self["published"] = False diff --git a/tests/test_lightblue.py b/tests/test_lightblue.py index ae2c54c..e2499dc 100644 --- a/tests/test_lightblue.py +++ b/tests/test_lightblue.py @@ -522,6 +522,34 @@ class TestContainerImageObject(helpers.FreshmakerTestCase): image.resolve_content_sets(lb) self.assertEqual(image["content_sets"], []) + def test_resolve_published(self): + image = ContainerImage.create({ + '_id': '1233829', + 'brew': { + 'build': 'package-name-1-4-12.10', + }, + }) + + lb = Mock() + lb.get_images_by_nvrs.return_value = [image] + image.resolve_published(lb) + self.assertEqual(image["published"], True) + lb.get_images_by_nvrs.assert_called_once_with( + ["package-name-1-4-12.10"], published=True) + + def test_resolve_published_unpublished(self): + image = ContainerImage.create({ + '_id': '1233829', + 'brew': { + 'build': 'package-name-1-4-12.10', + }, + }) + + lb = Mock() + lb.get_images_by_nvrs.return_value = [] + image.resolve_published(lb) + self.assertEqual(image["published"], False) + class TestContainerRepository(helpers.FreshmakerTestCase):