Merge "Add iter function to change list into iterator"

This commit is contained in:
Jenkins 2016-09-14 09:49:05 +00:00 committed by Gerrit Code Review
commit afe4209bb2
3 changed files with 23 additions and 6 deletions

View File

@ -868,7 +868,7 @@ class KollaWorker(object):
return
def list_children(images, ancestry):
children = six.next(ancestry.values())
children = six.next(iter(ancestry.values()))
for image in images:
if image.status not in [STATUS_MATCHED]:
continue

View File

@ -8,3 +8,4 @@ type = git
[profiles]
default = image-base
all = image-base,image-child

View File

@ -21,9 +21,14 @@ from kolla.image import build
from kolla.tests import base
FAKE_IMAGE = build.Image('image-base', 'image-base:latest',
FAKE_IMAGE = build.Image(
'image-base', 'image-base:latest',
'/fake/path', parent_name=None,
parent=None, status=build.STATUS_MATCHED)
FAKE_IMAGE_CHILD = build.Image(
'image-child', 'image-child:latest',
'/fake/path2', parent_name='image-base',
parent=FAKE_IMAGE, status=build.STATUS_MATCHED)
class TasksTest(base.TestCase):
@ -142,7 +147,9 @@ class KollaWorkerTest(base.TestCase):
super(KollaWorkerTest, self).setUp()
image = FAKE_IMAGE.copy()
image.status = None
self.images = [image]
image_child = FAKE_IMAGE_CHILD.copy()
image_child.status = None
self.images = [image, image_child]
def test_supported_base_type(self):
rh_base = ['fedora', 'centos', 'oraclelinux', 'rhel']
@ -197,7 +204,7 @@ class KollaWorkerTest(base.TestCase):
kolla.images = self.images
kolla.filter_images()
self.assertEqual(1, len(self._get_matched_images(kolla.images)))
self.assertEqual(2, len(self._get_matched_images(kolla.images)))
def test_pre_defined_exist_profile(self):
# default profile include the fake image: image-base
@ -225,6 +232,15 @@ class KollaWorkerTest(base.TestCase):
self.assertRaises(ValueError,
kolla.filter_images)
@mock.patch('pprint.pprint')
def test_list_dependencies(self, pprint_mock):
self.conf.set_override('profile', ['all'])
kolla = build.KollaWorker(self.conf)
kolla.images = self.images
kolla.filter_images()
kolla.list_dependencies()
pprint_mock.assert_called_once_with(mock.ANY)
@mock.patch.object(build, 'run_build')
class MainTest(base.TestCase):