From d56f570d3b78924e52f719337ddfd15848189761 Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Thu, 1 Sep 2016 10:49:14 -0400 Subject: [PATCH] Improve the imagetree test. --- test/test_imagetree.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/test_imagetree.py b/test/test_imagetree.py index 5189d9d7d..44b0fc10c 100644 --- a/test/test_imagetree.py +++ b/test/test_imagetree.py @@ -20,7 +20,8 @@ class TestImageTree(unittest.TestCase): finished_database_for_testing(self) 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: if image.ancestors == '/': return image @@ -90,29 +91,27 @@ class TestImageTree(unittest.TestCase): # still return the tag that contains them. self.assertEquals('staging', tree.tag_containing_image(result[0])) - def test_longest_path_simple_repo_direct_lookup(self): repository = model.repository.get_repository(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)) base_image = self._get_base_image(all_images) - tag_image = all_tags[0].image def checker(index, image): return True - filtered_images = model.image.get_repository_images_without_placements(repository, - with_ancestor=base_image) + filtered_images = model.image.get_repository_images_without_placements( + repository, + with_ancestor=base_image) self.assertEquals(set([f.id for f in filtered_images]), set([a.id for a in all_images])) 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) self.assertEquals(3, len(result)) self.assertEquals('latest', tree.tag_containing_image(result[-1])) + if __name__ == '__main__': unittest.main() -