Improve the imagetree test.
This commit is contained in:
parent
cf83c9a16a
commit
d56f570d3b
1 changed files with 6 additions and 7 deletions
|
@ -20,7 +20,8 @@ class TestImageTree(unittest.TestCase):
|
||||||
finished_database_for_testing(self)
|
finished_database_for_testing(self)
|
||||||
self.ctx.__exit__(True, None, None)
|
self.ctx.__exit__(True, None, None)
|
||||||
|
|
||||||
def _get_base_image(self, all_images):
|
@staticmethod
|
||||||
|
def _get_base_image(all_images):
|
||||||
for image in all_images:
|
for image in all_images:
|
||||||
if image.ancestors == '/':
|
if image.ancestors == '/':
|
||||||
return image
|
return image
|
||||||
|
@ -90,29 +91,27 @@ class TestImageTree(unittest.TestCase):
|
||||||
# still return the tag that contains them.
|
# still return the tag that contains them.
|
||||||
self.assertEquals('staging', tree.tag_containing_image(result[0]))
|
self.assertEquals('staging', tree.tag_containing_image(result[0]))
|
||||||
|
|
||||||
|
|
||||||
def test_longest_path_simple_repo_direct_lookup(self):
|
def test_longest_path_simple_repo_direct_lookup(self):
|
||||||
repository = model.repository.get_repository(NAMESPACE, SIMPLE_REPO)
|
repository = model.repository.get_repository(NAMESPACE, SIMPLE_REPO)
|
||||||
all_images = list(model.image.get_repository_images(NAMESPACE, SIMPLE_REPO))
|
all_images = list(model.image.get_repository_images(NAMESPACE, SIMPLE_REPO))
|
||||||
all_tags = list(model.tag.list_repository_tags(NAMESPACE, SIMPLE_REPO))
|
all_tags = list(model.tag.list_repository_tags(NAMESPACE, SIMPLE_REPO))
|
||||||
|
|
||||||
base_image = self._get_base_image(all_images)
|
base_image = self._get_base_image(all_images)
|
||||||
tag_image = all_tags[0].image
|
|
||||||
|
|
||||||
def checker(index, image):
|
def checker(index, image):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
filtered_images = model.image.get_repository_images_without_placements(repository,
|
filtered_images = model.image.get_repository_images_without_placements(
|
||||||
|
repository,
|
||||||
with_ancestor=base_image)
|
with_ancestor=base_image)
|
||||||
self.assertEquals(set([f.id for f in filtered_images]), set([a.id for a in all_images]))
|
self.assertEquals(set([f.id for f in filtered_images]), set([a.id for a in all_images]))
|
||||||
|
|
||||||
tree = ImageTree(filtered_images, all_tags)
|
tree = ImageTree(filtered_images, all_tags)
|
||||||
|
|
||||||
ancestors = tag_image.ancestors.split('/')[2:-1] # Skip the first image.
|
|
||||||
result = tree.find_longest_path(base_image.id, checker)
|
result = tree.find_longest_path(base_image.id, checker)
|
||||||
self.assertEquals(3, len(result))
|
self.assertEquals(3, len(result))
|
||||||
self.assertEquals('latest', tree.tag_containing_image(result[-1]))
|
self.assertEquals('latest', tree.tag_containing_image(result[-1]))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
Reference in a new issue