Merge pull request #463 from jzelinskie/fixpagination

fix pagination of tags in API
This commit is contained in:
Jimmy Zelinskie 2015-09-09 15:53:55 -04:00
commit ece08f6e88
3 changed files with 16 additions and 1 deletions

View file

@ -134,6 +134,7 @@ def list_repository_tag_history(repo_obj, page=1, size=100, specific_tag=None):
.where(RepositoryTag.repository == repo_obj)
.where(RepositoryTag.hidden == False)
.order_by(RepositoryTag.lifetime_start_ts.desc())
.order_by(RepositoryTag.name)
.paginate(page, size))
if specific_tag:

View file

@ -43,7 +43,7 @@ class ListRepositoryTags(RepositoryParamResource):
specific_tag = args.get('specificTag') or None
page = min(1, args.get('start', 1))
page = max(1, args.get('page', 1))
limit = min(100, max(1, args.get('limit', 50)))
# Note: We ask for limit+1 here, so we can check to see if there are

View file

@ -2079,6 +2079,7 @@ class TestRevertTag(ApiTestCase):
self.assertEquals(previous_image_id, json['tags'][0]['docker_image_id'])
class TestListAndDeleteTag(ApiTestCase):
def test_listdeletecreateandmovetag(self):
self.login(ADMIN_ACCESS_USER)
@ -2166,6 +2167,19 @@ class TestListAndDeleteTag(ApiTestCase):
self.assertEquals(prod_images, json['images'])
def test_listtagpagination(self):
self.login(ADMIN_ACCESS_USER)
for i in xrange(1, 100):
model.tag.create_or_update_tag(ADMIN_ACCESS_USER, "complex", "tag" + str(i),
"1d8cbff4e0363d1826c6a0b64ef0bc501d8cbff4e0363d1826c6a0b64ef0bc50")
json = self.getJsonResponse(ListRepositoryTags,
params=dict(repository=ADMIN_ACCESS_USER + '/complex', page=2))
# Make sure that we're able to see the second page of results.
assert json['page'] == 2
assert len(json['tags']) == 50
class TestRepoPermissions(ApiTestCase):
def listUserPermissions(self, namespace=ADMIN_ACCESS_USER, repo='simple'):