Add search tests
This commit is contained in:
parent
1b56567268
commit
40a6892a49
3 changed files with 92 additions and 9 deletions
|
@ -15,7 +15,7 @@ from data import model, database
|
|||
|
||||
from endpoints.api.team import TeamMember, TeamMemberList, TeamMemberInvite, OrganizationTeam
|
||||
from endpoints.api.tag import RepositoryTagImages, RepositoryTag
|
||||
from endpoints.api.search import FindRepositories, EntitySearch
|
||||
from endpoints.api.search import FindRepositories, EntitySearch, ConductSearch
|
||||
from endpoints.api.image import RepositoryImage, RepositoryImageList
|
||||
from endpoints.api.build import (RepositoryBuildStatus, RepositoryBuildLogs, RepositoryBuildList,
|
||||
RepositoryBuildResource)
|
||||
|
@ -472,6 +472,82 @@ class TestSignout(ApiTestCase):
|
|||
self.getJsonResponse(User, expected_code=401)
|
||||
|
||||
|
||||
class TestConductSearch(ApiTestCase):
|
||||
def test_noaccess(self):
|
||||
self.login(NO_ACCESS_USER)
|
||||
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='read'))
|
||||
|
||||
self.assertEquals(1, len(json['results']))
|
||||
self.assertEquals(json['results'][0]['kind'], 'user')
|
||||
self.assertEquals(json['results'][0]['name'], 'reader')
|
||||
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='owners'))
|
||||
|
||||
self.assertEquals(0, len(json['results']))
|
||||
|
||||
|
||||
def test_nouser(self):
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='read'))
|
||||
|
||||
self.assertEquals(1, len(json['results']))
|
||||
self.assertEquals(json['results'][0]['kind'], 'user')
|
||||
self.assertEquals(json['results'][0]['name'], 'reader')
|
||||
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='public'))
|
||||
|
||||
self.assertEquals(2, len(json['results']))
|
||||
self.assertEquals(json['results'][0]['kind'], 'user')
|
||||
self.assertEquals(json['results'][0]['name'], 'public')
|
||||
|
||||
self.assertEquals(json['results'][1]['kind'], 'repository')
|
||||
self.assertEquals(json['results'][1]['name'], 'publicrepo')
|
||||
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='owners'))
|
||||
|
||||
self.assertEquals(0, len(json['results']))
|
||||
|
||||
|
||||
def test_orgmember(self):
|
||||
self.login(READ_ACCESS_USER)
|
||||
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='owners'))
|
||||
|
||||
self.assertEquals(0, len(json['results']))
|
||||
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='readers'))
|
||||
|
||||
self.assertEquals(1, len(json['results']))
|
||||
self.assertEquals(json['results'][0]['kind'], 'team')
|
||||
self.assertEquals(json['results'][0]['name'], 'readers')
|
||||
|
||||
|
||||
def test_orgadmin(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='owners'))
|
||||
|
||||
self.assertEquals(1, len(json['results']))
|
||||
self.assertEquals(json['results'][0]['kind'], 'team')
|
||||
self.assertEquals(json['results'][0]['name'], 'owners')
|
||||
|
||||
json = self.getJsonResponse(ConductSearch,
|
||||
params=dict(query='readers'))
|
||||
|
||||
self.assertEquals(1, len(json['results']))
|
||||
self.assertEquals(json['results'][0]['kind'], 'team')
|
||||
self.assertEquals(json['results'][0]['name'], 'readers')
|
||||
|
||||
|
||||
|
||||
class TestGetMatchingEntities(ApiTestCase):
|
||||
def test_notinorg(self):
|
||||
self.login(NO_ACCESS_USER)
|
||||
|
|
Reference in a new issue