Add ability to tag images from the UI, including moving existing tags to different images

This commit is contained in:
Joseph Schorr 2014-02-28 00:12:09 -05:00
parent 9371c70941
commit 20ad666308
11 changed files with 581 additions and 200 deletions

Binary file not shown.

View file

@ -68,6 +68,9 @@ UPDATE_REPO_DETAILS = {
'description': 'A new description',
}
CHANGE_TAG_IMAGE_DETAILS = {
'image': FAKE_IMAGE_ID
}
class TestSpec(object):
def __init__(self, url, anon_code=401, no_access_code=403, read_code=403,
@ -425,6 +428,12 @@ def build_specs():
TestSpec(url_for('api.list_repo_logs', repository=PRIVATE_REPO)),
TestSpec(url_for('api.list_org_logs', orgname=ORG)),
TestSpec(url_for('api.delete_full_tag', repository=PRIVATE_REPO, tag='latest'), 403, 403, 403, 204)
.set_method('DELETE'),
TestSpec(url_for('api.change_tag_image', repository=PRIVATE_REPO, tag='latest'), 403, 403, 403, 404)
.set_method('PUT').set_data_from_obj(CHANGE_TAG_IMAGE_DETAILS),
]

View file

@ -55,6 +55,13 @@ class ApiTestCase(unittest.TestCase):
self.assertEquals(rv.status_code, expected_code)
return rv.data
def putResponse(self, method_name, params={}, data={}, expected_code=200):
rv = self.app.put(url_for(method_name, **params),
data=py_json.dumps(data),
headers={"Content-Type": "application/json"})
self.assertEquals(rv.status_code, expected_code)
return rv.data
def deleteResponse(self, method_name, params={}, expected_code=204):
rv = self.app.delete(url_for(method_name, **params))
self.assertEquals(rv.status_code, expected_code)
@ -961,7 +968,7 @@ class TestGetImageChanges(ApiTestCase):
class TestListAndDeleteTag(ApiTestCase):
def test_listtagimagesanddeletetag(self):
def test_listdeletecreateandmovetag(self):
self.login(ADMIN_ACCESS_USER)
# List the images for prod.
@ -994,6 +1001,33 @@ class TestListAndDeleteTag(ApiTestCase):
self.assertEquals(staging_images, json['images'])
# Add a new tag to the staging image.
self.putResponse('api.change_tag_image',
params=dict(repository=ADMIN_ACCESS_USER + '/complex', tag='sometag'),
data=dict(image=staging_images[0]['id']),
expected_code=201)
# Make sure the tag is present.
json = self.getJsonResponse('api.list_tag_images',
params=dict(repository=ADMIN_ACCESS_USER + '/complex', tag='sometag'))
sometag_images = json['images']
self.assertEquals(sometag_images, staging_images)
# Move the tag.
self.putResponse('api.change_tag_image',
params=dict(repository=ADMIN_ACCESS_USER + '/complex', tag='sometag'),
data=dict(image=staging_images[-1]['id']),
expected_code=201)
# Make sure the tag has moved.
json = self.getJsonResponse('api.list_tag_images',
params=dict(repository=ADMIN_ACCESS_USER + '/complex', tag='sometag'))
sometag_new_images = json['images']
self.assertEquals(1, len(sometag_new_images))
self.assertEquals(staging_images[-1], sometag_new_images[0])
def test_deletesubtag(self):
self.login(ADMIN_ACCESS_USER)