Remove unused imagetree class
This commit is contained in:
parent
6f8ec1deac
commit
f9f47e68c3
3 changed files with 0 additions and 182 deletions
|
@ -1,82 +0,0 @@
|
|||
from data import model
|
||||
from util.imagetree import ImageTree
|
||||
|
||||
from test.fixtures import *
|
||||
|
||||
NAMESPACE = 'devtable'
|
||||
SIMPLE_REPO = 'simple'
|
||||
COMPLEX_REPO = 'complex'
|
||||
|
||||
def _get_base_image(all_images):
|
||||
for image in all_images:
|
||||
if image.ancestors == '/':
|
||||
return image
|
||||
|
||||
return None
|
||||
|
||||
def test_longest_path_simple_repo(initialized_db):
|
||||
all_images = list(model.image.get_repository_images(NAMESPACE, SIMPLE_REPO))
|
||||
all_tags = list(model.tag.list_repository_tags(NAMESPACE, SIMPLE_REPO))
|
||||
tree = ImageTree(all_images, all_tags)
|
||||
|
||||
base_image = _get_base_image(all_images)
|
||||
tag_image = all_tags[0].image
|
||||
|
||||
def checker(index, image):
|
||||
return True
|
||||
|
||||
ancestors = tag_image.ancestors.split('/')[2:-1] # Skip the first image.
|
||||
result = tree.find_longest_path(base_image.id, checker)
|
||||
assert len(result) == 3
|
||||
for index in range(0, 2):
|
||||
assert result[index].id == int(ancestors[index])
|
||||
|
||||
assert tree.tag_containing_image(result[-1]) == 'latest'
|
||||
|
||||
def test_longest_path_complex_repo(initialized_db):
|
||||
all_images = list(model.image.get_repository_images(NAMESPACE, COMPLEX_REPO))
|
||||
all_tags = list(model.tag.list_repository_tags(NAMESPACE, COMPLEX_REPO))
|
||||
tree = ImageTree(all_images, all_tags)
|
||||
|
||||
base_image = _get_base_image(all_images)
|
||||
|
||||
def checker(index, image):
|
||||
return True
|
||||
|
||||
result = tree.find_longest_path(base_image.id, checker)
|
||||
assert len(result) == 5
|
||||
assert tree.tag_containing_image(result[-1]) == 'prod'
|
||||
|
||||
def test_filtering(initialized_db):
|
||||
all_images = list(model.image.get_repository_images(NAMESPACE, COMPLEX_REPO))
|
||||
all_tags = list(model.tag.list_repository_tags(NAMESPACE, COMPLEX_REPO))
|
||||
tree = ImageTree(all_images, all_tags, base_filter=1245)
|
||||
|
||||
base_image = _get_base_image(all_images)
|
||||
|
||||
def checker(index, image):
|
||||
return True
|
||||
|
||||
result = tree.find_longest_path(base_image.id, checker)
|
||||
assert len(result) == 0
|
||||
|
||||
def test_longest_path_simple_repo_direct_lookup(initialized_db):
|
||||
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 = _get_base_image(all_images)
|
||||
|
||||
def checker(index, image):
|
||||
return True
|
||||
|
||||
filtered_images = model.image.get_repository_images_without_placements(
|
||||
repository,
|
||||
with_ancestor=base_image)
|
||||
assert set([a.id for a in all_images]) == set([f.id for f in filtered_images])
|
||||
|
||||
tree = ImageTree(filtered_images, all_tags)
|
||||
|
||||
result = tree.find_longest_path(base_image.id, checker)
|
||||
assert len(result) == 3
|
||||
assert tree.tag_containing_image(result[-1]) == 'latest'
|
Reference in a new issue