tests: add test for star/unstar repo
This commit is contained in:
parent
46832676f7
commit
2914a5da96
1 changed files with 38 additions and 3 deletions
|
@ -28,7 +28,7 @@ from endpoints.api.repoemail import RepositoryAuthorizedEmail
|
|||
from endpoints.api.repositorynotification import RepositoryNotification, RepositoryNotificationList
|
||||
from endpoints.api.user import (PrivateRepositories, ConvertToOrganization, Signout, Signin, User,
|
||||
UserAuthorizationList, UserAuthorization, UserNotification,
|
||||
UserNotificationList)
|
||||
UserNotificationList, StarredRepositoryList, StarredRepository)
|
||||
|
||||
from endpoints.api.repotoken import RepositoryToken, RepositoryTokenList
|
||||
from endpoints.api.prototype import PermissionPrototype, PermissionPrototypeList
|
||||
|
@ -224,6 +224,42 @@ class TestLoggedInUser(ApiTestCase):
|
|||
assert json['anonymous'] == False
|
||||
assert json['username'] == READ_ACCESS_USER
|
||||
|
||||
class TestUserStarredRepositoryList(ApiTestCase):
|
||||
def test_get_stars_guest(self):
|
||||
self.getJsonResponse(StarredRepositoryList, expected_code=401)
|
||||
|
||||
def test_get_stars_user(self):
|
||||
self.login(READ_ACCESS_USER)
|
||||
self.getJsonResponse(StarredRepositoryList, expected_code=200)
|
||||
|
||||
def test_star_repo_guest(self):
|
||||
self.postJsonResponse(StarredRepositoryList,
|
||||
data={
|
||||
'namespace': 'public',
|
||||
'repository': 'publicrepo',
|
||||
},
|
||||
expected_code=401)
|
||||
|
||||
def test_unstar_repo_guest(self):
|
||||
self.deleteResponse(StarredRepository, params=dict(repository='public/publicrepo'), expected_code=401)
|
||||
|
||||
def test_star_and_unstar_repo_user(self):
|
||||
self.login(READ_ACCESS_USER)
|
||||
json = self.getJsonResponse(StarredRepositoryList)
|
||||
assert json['repositories'] == []
|
||||
|
||||
json = self.postJsonResponse(StarredRepositoryList,
|
||||
data={
|
||||
'namespace': 'public',
|
||||
'repository': 'publicrepo',
|
||||
},
|
||||
expected_code=201)
|
||||
assert json['namespace'] == 'public'
|
||||
assert json['repository'] == 'publicrepo'
|
||||
|
||||
self.deleteResponse(StarredRepository, params=dict(repository='public/publicrepo'), expected_code=204)
|
||||
|
||||
|
||||
|
||||
class TestUserNotification(ApiTestCase):
|
||||
def test_get(self):
|
||||
|
@ -726,7 +762,7 @@ class TestUpdateOrganizationTeam(ApiTestCase):
|
|||
|
||||
self.putJsonResponse(OrganizationTeam,
|
||||
params=dict(orgname=ORGANIZATION, teamname='owners'),
|
||||
data=dict(role = 'creator'),
|
||||
data=dict(role='creator'),
|
||||
expected_code=400)
|
||||
|
||||
def test_createnewteam(self):
|
||||
|
@ -1304,7 +1340,6 @@ class TestGetRepository(ApiTestCase):
|
|||
self.assertEquals(True, json['is_organization'])
|
||||
|
||||
|
||||
|
||||
class TestRepositoryBuildResource(ApiTestCase):
|
||||
def test_cancel_invalidbuild(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
|
Reference in a new issue