parent
1c4d3326c2
commit
7f5b536ddb
5 changed files with 70 additions and 39 deletions
|
@ -1447,12 +1447,11 @@ class TestCreateRepo(ApiTestCase):
|
|||
class TestListRepos(ApiTestCase):
|
||||
def test_listrepos_asguest(self):
|
||||
# Queries: Base + the list query
|
||||
# TODO: uncomment once fixed
|
||||
#with assert_query_count(BASE_QUERY_COUNT + 1):
|
||||
json = self.getJsonResponse(RepositoryList, params=dict(public=True))
|
||||
self.assertEquals(len(json['repositories']), 1)
|
||||
with assert_query_count(BASE_QUERY_COUNT + 1):
|
||||
json = self.getJsonResponse(RepositoryList, params=dict(public=True))
|
||||
self.assertEquals(len(json['repositories']), 1)
|
||||
|
||||
def test_listrepos_asguest_withpages(self):
|
||||
def assertPublicRepos(self, has_extras=False):
|
||||
public_user = model.user.get_user('public')
|
||||
|
||||
# Delete all existing repos under the namespace.
|
||||
|
@ -1461,7 +1460,7 @@ class TestListRepos(ApiTestCase):
|
|||
|
||||
# Add public repos until we have enough for a few pages.
|
||||
required = set()
|
||||
for i in range(0, REPOS_PER_PAGE * 2):
|
||||
for i in range(0, REPOS_PER_PAGE * 3):
|
||||
name = 'publicrepo%s' % i
|
||||
model.repository.create_repository('public', name, public_user,
|
||||
visibility='public')
|
||||
|
@ -1473,8 +1472,10 @@ class TestListRepos(ApiTestCase):
|
|||
json = self.getJsonResponse(RepositoryList, params=dict(public=True, next_page=next_page))
|
||||
for repo in json['repositories']:
|
||||
name = repo['name']
|
||||
self.assertTrue(name in required)
|
||||
required.remove(name)
|
||||
if name in required:
|
||||
required.remove(name)
|
||||
else:
|
||||
self.assertTrue(has_extras, "Could not find name %s in repos created" % name)
|
||||
|
||||
if 'next_page' in json:
|
||||
self.assertEquals(len(json['repositories']), REPOS_PER_PAGE)
|
||||
|
@ -1483,13 +1484,12 @@ class TestListRepos(ApiTestCase):
|
|||
|
||||
next_page = json['next_page']
|
||||
|
||||
# Ensure we found all the repositories.
|
||||
self.assertEquals(0, len(required))
|
||||
def test_listrepos_asguest_withpages(self):
|
||||
self.assertPublicRepos()
|
||||
|
||||
def test_listrepos_asorgmember(self):
|
||||
def test_listrepos_asorgmember_withpages(self):
|
||||
self.login(READ_ACCESS_USER)
|
||||
json = self.getJsonResponse(RepositoryList, params=dict(public=True))
|
||||
self.assertGreater(len(json['repositories']), 0)
|
||||
self.assertPublicRepos(has_extras=True)
|
||||
|
||||
def test_listrepos_filter(self):
|
||||
self.login(READ_ACCESS_USER)
|
||||
|
|
Reference in a new issue