Merge "Add iter function to change list into iterator"
This commit is contained in:
commit
afe4209bb2
@ -868,7 +868,7 @@ class KollaWorker(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def list_children(images, ancestry):
|
def list_children(images, ancestry):
|
||||||
children = six.next(ancestry.values())
|
children = six.next(iter(ancestry.values()))
|
||||||
for image in images:
|
for image in images:
|
||||||
if image.status not in [STATUS_MATCHED]:
|
if image.status not in [STATUS_MATCHED]:
|
||||||
continue
|
continue
|
||||||
|
@ -8,3 +8,4 @@ type = git
|
|||||||
|
|
||||||
[profiles]
|
[profiles]
|
||||||
default = image-base
|
default = image-base
|
||||||
|
all = image-base,image-child
|
||||||
|
@ -21,9 +21,14 @@ from kolla.image import build
|
|||||||
from kolla.tests import base
|
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,
|
'/fake/path', parent_name=None,
|
||||||
parent=None, status=build.STATUS_MATCHED)
|
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):
|
class TasksTest(base.TestCase):
|
||||||
@ -142,7 +147,9 @@ class KollaWorkerTest(base.TestCase):
|
|||||||
super(KollaWorkerTest, self).setUp()
|
super(KollaWorkerTest, self).setUp()
|
||||||
image = FAKE_IMAGE.copy()
|
image = FAKE_IMAGE.copy()
|
||||||
image.status = None
|
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):
|
def test_supported_base_type(self):
|
||||||
rh_base = ['fedora', 'centos', 'oraclelinux', 'rhel']
|
rh_base = ['fedora', 'centos', 'oraclelinux', 'rhel']
|
||||||
@ -197,7 +204,7 @@ class KollaWorkerTest(base.TestCase):
|
|||||||
kolla.images = self.images
|
kolla.images = self.images
|
||||||
kolla.filter_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):
|
def test_pre_defined_exist_profile(self):
|
||||||
# default profile include the fake image: image-base
|
# default profile include the fake image: image-base
|
||||||
@ -225,6 +232,15 @@ class KollaWorkerTest(base.TestCase):
|
|||||||
self.assertRaises(ValueError,
|
self.assertRaises(ValueError,
|
||||||
kolla.filter_images)
|
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')
|
@mock.patch.object(build, 'run_build')
|
||||||
class MainTest(base.TestCase):
|
class MainTest(base.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user