Add a test for get_matching_tags
This commit is contained in:
		
							parent
							
								
									8552f7f6e6
								
							
						
					
					
						commit
						8b2e4d3bcf
					
				
					 1 changed files with 18 additions and 1 deletions
				
			
		|  | @ -1,8 +1,25 @@ | |||
| from data.database import Image, RepositoryTag | ||||
| from data.model.repository import create_repository | ||||
| from data.model.tag import list_active_repo_tags, create_or_update_tag, delete_tag | ||||
| from data.model.tag import (list_active_repo_tags, create_or_update_tag, delete_tag, | ||||
|                             get_matching_tags, _tag_alive) | ||||
| from data.model.image import find_create_or_link_image | ||||
| 
 | ||||
| from test.fixtures import * | ||||
| 
 | ||||
| def test_get_matching_tags(initialized_db): | ||||
|   # Test for every image in the test database. | ||||
|   for image in Image.select(): | ||||
|     matching_query = get_matching_tags(image.docker_image_id, image.storage.uuid) | ||||
|     expected_query = (RepositoryTag | ||||
|                       .select() | ||||
|                       .join(Image) | ||||
|                       .where(RepositoryTag.hidden == False) | ||||
|                       .where((Image.id == image.id) | (Image.ancestors ** ('%%/%s/%%' % image.id)))) | ||||
| 
 | ||||
|     matching_tags = set([tag.id for tag in matching_query]) | ||||
|     expected_tags = set([tag.id for tag in _tag_alive(expected_query)]) | ||||
|     assert matching_tags == expected_tags, "mismatch for image %s" % image.id | ||||
| 
 | ||||
| def assert_tags(repository, *args): | ||||
|   tags = list(list_active_repo_tags(repository)) | ||||
|   assert len(tags) == len(args) | ||||
|  |  | |||
		Reference in a new issue