Remove getRepoPermission from FakeGithubConnection
This shadows the original method of the GithubConnection and thus prevents testing it. Change-Id: I550ff1bfcd48ebeae1cc403a6873f61253f7258a
This commit is contained in:
parent
0445d03542
commit
f8b6cdb40c
|
@ -1106,18 +1106,6 @@ class FakeGithubConnection(githubconnection.GithubConnection):
|
|||
pr = self.pull_requests[number]
|
||||
return pr.reviews
|
||||
|
||||
def getRepoPermission(self, project, login):
|
||||
owner, proj = project.split('/')
|
||||
for pr in self.pull_requests.values():
|
||||
pr_owner, pr_project = pr.project.split('/')
|
||||
if (pr_owner == owner and proj == pr_project):
|
||||
if login in pr.admins:
|
||||
return 'admin'
|
||||
elif login in pr.writers:
|
||||
return 'write'
|
||||
else:
|
||||
return 'read'
|
||||
|
||||
def getGitUrl(self, project):
|
||||
if self.git_url_with_auth:
|
||||
auth_token = ''.join(
|
||||
|
|
|
@ -113,6 +113,8 @@ class FakeRepository(object):
|
|||
|
||||
if entity == 'branches':
|
||||
return self.get_url_branch(request)
|
||||
if entity == 'collaborators':
|
||||
return self.get_url_collaborators(request)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
@ -124,6 +126,30 @@ class FakeRepository(object):
|
|||
else:
|
||||
return None
|
||||
|
||||
def get_url_collaborators(self, path):
|
||||
login, entity = path.split('/')
|
||||
|
||||
if entity == 'permission':
|
||||
owner, proj = self.name.split('/')
|
||||
permission = None
|
||||
for pr in self.data.pull_requests.values():
|
||||
pr_owner, pr_project = pr.project.split('/')
|
||||
if (pr_owner == owner and proj == pr_project):
|
||||
if login in pr.admins:
|
||||
permission = 'admin'
|
||||
break
|
||||
elif login in pr.writers:
|
||||
permission = 'write'
|
||||
break
|
||||
else:
|
||||
permission = 'read'
|
||||
data = {
|
||||
'permission': permission,
|
||||
}
|
||||
return FakeResponse(data)
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_url_protection(self, branch):
|
||||
contexts = self.data.required_contexts.get((self.name, branch), [])
|
||||
data = {
|
||||
|
|
Loading…
Reference in New Issue