Commit f4ec3c60 authored by Vamshi Krishna's avatar Vamshi Krishna

Issue: Add available_assignees property

parent fff0d568
Pipeline #27067020 passed with stages
in 2 minutes and 34 seconds
......@@ -161,6 +161,26 @@ class GitHubIssue(GitHubMixin, Issue):
{'assignees': [user.username for user in users]})
self.data = get(self._token, self.url)
@property
def available_assignees(self) -> Set[GitHubUser]:
"""
Retrieves a set of available assignees for the issue.
>>> from os import environ
>>> issue = GitHubIssue(GitHubToken(environ['GITHUB_TEST_TOKEN']),
... 'gitmate-test-user/test', 1)
>>> {a.username for a in issue.available_assignees}
{'gitmate-test-user'}
:return: A set of GitHubUsers.
"""
return {
GitHubUser.from_data(user, self._token, user['login'])
for user in get(
self._token,
self.absolute_url('/repos/' + self._repository + '/assignees'))
}
@property
def description(self):
r"""
......
......@@ -151,6 +151,26 @@ class GitLabIssue(GitLabMixin, Issue):
self.data = put(self._token, self.url,
{'assignee_ids': [u.identifier for u in value]})
@property
def available_assignees(self) -> Set[GitLabUser]:
"""
Retrieves a set of available assignees for the issue.
>>> from os import environ
>>> issue = GitLabIssue(GitLabOAuthToken(environ['GITLAB_TEST_TOKEN']),
... 'gitmate-test-user/test', 1)
>>> {a.username for a in issue.available_assignees}
{'gitmate-test-user'}
:return: A set of GitLabUsers.
"""
return {
GitLabUser.from_data(user, self._token, user['id'])
for user in get(
self._token, self.absolute_url(
'/projects/' + quote_plus(self._repository) + '/members'))
}
@property
def description(self) -> str:
r"""
......
......@@ -98,6 +98,15 @@ class Issue(IGittObject):
"""
raise NotImplementedError
@property
def available_assignees(self) -> Set[User]:
"""
Compiles a set of Users that are available for assigning this issue.
:return: A set of User objects.
"""
raise NotImplementedError
@property
def labels(self) -> Set[str]:
"""
......
......@@ -406,4 +406,59 @@ interactions:
X-Runtime-rack: ['0.073604']
X-XSS-Protection: [1; mode=block]
status: {code: 200, message: OK}
- request:
body: '{}'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['2']
Content-Type: [application/json]
User-Agent: [IGitt]
method: GET
uri: https://api.github.com/repos/gitmate-test-user/test/assignees?per_page=100
response:
body:
string: !!binary |
H4sIAAAAAAAAA62WW2+bMBiG/wvXaTk1h0aqpkrpJa0mNdOmqYoc4hInBBA2OTTqf99ncFLMSDbb
3EXoex+/hjyY30crTiOSWGMrImyDGL5hmLKbguLc6llkYY3dwWDkOr7Ts5J0gWf8khVMvg9+/HyO
w9WT97yK9sEk2ME42iKG8lmRxzCzZCyjY9uuLlL/FhZYFnNODtOE4YTdhunGLuzTAt+2D3cAiXKB
KVeCCw1cRgSpigOO2m3dl2wTN6pUDcpcW+I9jeN0B7zmDv5rSfsch87Vb5JEJiiIH+2ULTHcUtjm
J785hDLNemX0CBunDB4ih1F4WDle6FUUYSi4S6Db0c5xlpbUYk7DnGSMpIlmVQkByDSPUEI+kAES
EBRIvKRmqTIKCLyFv64mo8oe7SwnWxQe+O3KcYjJFp6CCbcBASw7ZBj0mVYeU8LwDC02XPR3FFP8
2fsSf4MxmJ9ExZocEES5d8OB5/R9v9350AtWj27wETzA9DXnnYvOC76B8s3W13VvTiupLoX1NW/D
mCgu84z0llHdqd3g1t8MOlrLOFWl5bS6znK+G5WbnaR3gZrGyRreKkmIHWcoJHaHnuON7i+d3D5Y
fHiZrA1ObrGAgcZy6+sSy7NKCtei+gL/DTHRt04zkrcO6k5diWoqbh2mqm09qy5tPd2NsnIfA2Ep
nseInVwdOX333nHbT9ynu2Ay3b+8Pu61T1xXLGDg6rnwdU3PY0qGVil9OaW8iZcCZKSkYHRn4wlo
KqLgqDooYur6iWA35p1bmEhHYv4Rz79x+0N30PcunI5TP3j95cIJqf+NK/gmwlVl/6FbNaQmG2QM
VPtKG4nGMWaacUKHkpU4Y8U4RVkwHtLQi8c6kqtqoKrW2x/wHdAeQhIAAA==
headers:
Access-Control-Allow-Origin: ['*']
Access-Control-Expose-Headers: ['ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit,
X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes,
X-Poll-Interval']
Cache-Control: ['private, max-age=60, s-maxage=60']
Content-Encoding: [gzip]
Content-Security-Policy: [default-src 'none']
Content-Type: [application/json; charset=utf-8]
Date: ['Wed, 01 Aug 2018 13:44:28 GMT']
ETag: [W/"6e4b400a4e841f261dce95b877dfe25b"]
Referrer-Policy: ['origin-when-cross-origin, strict-origin-when-cross-origin']
Server: [GitHub.com]
Status: [200 OK]
Strict-Transport-Security: [max-age=31536000; includeSubdomains; preload]
Vary: ['Accept, Authorization, Cookie, X-GitHub-OTP']
X-Accepted-OAuth-Scopes: [repo]
X-Content-Type-Options: [nosniff]
X-Frame-Options: [deny]
X-GitHub-Media-Type: [github.v3; format=json]
X-GitHub-Request-Id: ['085F:1F3B:2FF363A:5EAD437:5B61B93B']
X-OAuth-Scopes: ['admin:gpg_key, admin:org, admin:org_hook, admin:public_key,
admin:repo_hook, gist, notifications, repo, user']
X-RateLimit-Limit: ['5000']
X-RateLimit-Remaining: ['4998']
X-RateLimit-Reset: ['1533134341']
X-Runtime-rack: ['0.048697']
X-XSS-Protection: [1; mode=block]
status: {code: 200, message: OK}
version: 1
......@@ -38,6 +38,7 @@ class GitHubIssueTest(IGittTestCase):
self.assertEqual(iss.assignees, set())
iss = GitHubIssue(self.token, 'gitmate-test-user/test', 107)
self.assertEqual(iss.assignees, set())
self.assertEqual(len(iss.available_assignees), 5)
def test_number(self):
self.assertEqual(self.iss.number, 39)
......
......@@ -145,4 +145,60 @@ interactions:
X-Request-Id: [c08bc098-65ee-4325-9eb5-c745eaba5923]
X-Runtime: ['0.395186']
status: {code: 200, message: OK}
- request:
body: '{}'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['2']
Content-Type: [application/json]
User-Agent: [IGitt]
method: GET
uri: https://gitlab.com/api/v4/projects/gitmate-test-user%2Ftest/members?per_page=100
response:
body: {string: "[{\"id\":1369631,\"name\":\"GitMate Labs \U0001F47D\",\"username\"\
:\"gitmate-test-user\",\"state\":\"active\",\"avatar_url\":\"https://assets.gitlab-static.net/uploads/-/system/user/avatar/1369631/avatar.png\"\
,\"web_url\":\"https://gitlab.com/gitmate-test-user\",\"access_level\":40,\"\
expires_at\":null},{\"id\":889700,\"name\":\"Naveen Kumar Sangi\U0001F984\"\
,\"username\":\"nkprince007\",\"state\":\"active\",\"avatar_url\":\"https://secure.gravatar.com/avatar/2ed27920a4ec4445d0e390a30df7145d?s=80\\\
u0026d=identicon\",\"web_url\":\"https://gitlab.com/nkprince007\",\"access_level\"\
:40,\"expires_at\":null},{\"id\":707601,\"name\":\"Meet Mangukiya\",\"username\"\
:\"meetmangukiya\",\"state\":\"active\",\"avatar_url\":\"https://assets.gitlab-static.net/uploads/-/system/user/avatar/707601/avatar.png\"\
,\"web_url\":\"https://gitlab.com/meetmangukiya\",\"access_level\":30,\"expires_at\"\
:null},{\"id\":1399318,\"name\":\"GitMate Bot\",\"username\":\"gitmate-bot\"\
,\"state\":\"active\",\"avatar_url\":\"https://assets.gitlab-static.net/uploads/-/system/user/avatar/1399318/avatar.png\"\
,\"web_url\":\"https://gitlab.com/gitmate-bot\",\"access_level\":40,\"expires_at\"\
:null},{\"id\":463976,\"name\":\"Sebastian Latacz\",\"username\":\"seblat\"\
,\"state\":\"active\",\"avatar_url\":\"https://assets.gitlab-static.net/uploads/-/system/user/avatar/463976/avatar.png\"\
,\"web_url\":\"https://gitlab.com/seblat\",\"access_level\":30,\"expires_at\"\
:null}]"}
headers:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Length: ['1301']
Content-Type: [application/json]
Date: ['Wed, 01 Aug 2018 13:44:42 GMT']
Etag: [W/"12deb2a6ad0f92a91a2b68e338d56de3"]
Link: ['<https://gitlab.com/api/v4/projects/gitmate-test-user%2Ftest/members?id=gitmate-test-user%2Ftest&page=1&per_page=100>;
rel="first", <https://gitlab.com/api/v4/projects/gitmate-test-user%2Ftest/members?id=gitmate-test-user%2Ftest&page=1&per_page=100>;
rel="last"']
RateLimit-Limit: ['600']
RateLimit-Observed: ['1']
RateLimit-Remaining: ['599']
RateLimit-Reset: ['1533131142']
RateLimit-ResetTime: ['Thu, 01 Aug 2018 13:45:42 GMT']
Server: [nginx]
Strict-Transport-Security: [max-age=31536000]
Vary: [Origin]
X-Content-Type-Options: [nosniff]
X-Frame-Options: [SAMEORIGIN]
X-Next-Page: ['']
X-Page: ['1']
X-Per-Page: ['100']
X-Prev-Page: ['']
X-Request-Id: [1ea8b89e-17b5-4126-bf1f-32ce34322cab]
X-Runtime: ['0.084994']
X-Total: ['5']
X-Total-Pages: ['1']
status: {code: 200, message: OK}
version: 1
......@@ -39,6 +39,7 @@ class GitLabIssueTest(IGittTestCase):
self.assertEqual(iss.assignees, set())
iss = GitLabIssue(self.token, 'gitmate-test-user/test', 2)
self.assertEqual(iss.assignees, set())
self.assertEqual(len(iss.available_assignees), 5)
def test_number(self):
self.assertEqual(self.iss.number, 3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment