Commit 71ef0894 authored by Meet Mangukiya's avatar Meet Mangukiya

IGitt: Implement setters for assignee property

Closes #53
parent 41656b9a
Pipeline #8971056 passed with stage
in 2 minutes and 35 seconds
......@@ -13,6 +13,7 @@ pylint_disable = R0903, C0411, C0326, C1801, W0231, R0913
[python.code]
files = **/*.py
ignore = tests/**.py
pylint_disable += E1126
[python.tests]
files = tests/**.py
......
......@@ -112,6 +112,13 @@ class GitHubIssue(Issue):
return (self._data['assignee']['login'] if self._data['assignee'] else
None)
@assignee.setter
def assignee(self, new_assignee):
self._data = post(self._token,
'/repos/{}/issues/{}/assignees'.format(self._repository,
self.number),
{'assignees': new_assignee})
@property
def description(self):
r"""
......
......@@ -119,6 +119,15 @@ class GitLabIssue(Issue):
return (self._data['assignees'][0]['username']
if self._data['assignees'] else None)
@assignee.setter
def assignee(self, new_assignee):
url = self._url.format(quote_plus(self._repository),
self.number)
res = get(self._token, '/users', {'username': new_assignee})
if len(res) > 0:
user = res[0]['id']
self._data = put(self._token, url, {'assignee_ids': user})
@property
def description(self) -> str:
r"""
......
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [python-requests/2.17.3]
method: GET
uri: https://api.github.com/repos/gitmate-test-user/test/issues/41?User-Agent=IGitt
response:
body:
string: !!binary |
H4sIAAAAAAAAA62UXW+bMBSG/8rk66QOkLQd0tQ/0d5smiIDp8SqsZFtqDKU/77XJklXFvUDVeLC
2Od9fHy+BtZZxXK28751OeeilVe19LuuuCpNwy21xnFsNMLT0pPzy86R5WHFpXMdOb5O2IJFQ+mN
3W9nA4FRoiDl5iNefOIjauBaNHQAGs9pSPuvgZ9g4FL/ZdQRBebON2oShH+S8oF0yIrlaZbdrjeb
ze2C6a4pyLJ8nSyYl14RMh5S+G38WbCQVJYPTJlaahw2REi5rrsnuRdwKPBurtPVJssWTPTCCztN
Utx02bF6ArA02iM2sZA6fpTf9T8yAGt7pAQyw8abVRNojk+dejtKU+tHo5R5Bmfq+OuKv3AVP0vh
57iWup6LgXTgxu8IEcSzQmnW0r1Xl5fcirIB3en8VlYB5JACS9XnXTsK4dizhk9DbPxI7ApXWtl6
afSMyL2SA2dsLbT8I2biIHegxGHz+UdGGeQf6dhL8R51A2+t7EW5D+GxVJLsEfG5zAkASL9vQ3s+
hI5E/KWnraia0JWPQjk6nIYky3/9jhn3wdy0pGGuTPlE6Khoik51TtaaYKA7pV7+3ShupMIQMPp8
fh5r+QoD0xLY1VZ48NNVcrNcXeO7T1Z5mubZ+ifu69rqf5skvU++Y9bkWRZsSmXcETN6UZhqfxpA
cX22KbAfbA5/AZmkV8eXBgAA
headers:
Access-Control-Allow-Origin: ['*']
Access-Control-Expose-Headers: ['ETag, Link, 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: ['Mon, 12 Jun 2017 19:45:39 GMT']
ETag: [W/"2170a3ecaaa6524ba0a9585b3f79de9e"]
Last-Modified: ['Mon, 12 Jun 2017 19:41:33 GMT']
Server: [GitHub.com]
Status: [200 OK]
Strict-Transport-Security: [max-age=31536000; includeSubdomains; preload]
Vary: ['Accept, Authorization, Cookie, X-GitHub-OTP', Accept-Encoding]
X-Accepted-OAuth-Scopes: ['public_repo, repo']
X-Content-Type-Options: [nosniff]
X-Frame-Options: [deny]
X-GitHub-Media-Type: [github.v3; format=json]
X-GitHub-Request-Id: ['91CC:1B58B:33E00D7:43538C4:593EEF62']
X-OAuth-Scopes: ['admin:gpg_key, admin:org, admin:org_hook, admin:public_key,
admin:repo_hook, delete_repo, gist, notifications, repo, user']
X-RateLimit-Limit: ['5000']
X-RateLimit-Remaining: ['4961']
X-RateLimit-Reset: ['1497297359']
X-Runtime-rack: ['0.058389']
X-Served-By: [9e60649f02cd840ee8baa9960690f79f]
X-XSS-Protection: [1; mode=block]
status: {code: 200, message: OK}
- request:
body: '{"assignees": "meetmangukiya"}'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['30']
Content-Type: [application/json]
User-Agent: [python-requests/2.17.3]
method: POST
uri: https://api.github.com/repos/gitmate-test-user/test/issues/41/assignees?User-Agent=IGitt
response:
body: {string: '{"url":"https://api.github.com/repos/gitmate-test-user/test/issues/41","repository_url":"https://api.github.com/repos/gitmate-test-user/test","labels_url":"https://api.github.com/repos/gitmate-test-user/test/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/gitmate-test-user/test/issues/41/comments","events_url":"https://api.github.com/repos/gitmate-test-user/test/issues/41/events","html_url":"https://github.com/gitmate-test-user/test/issues/41","id":233845558,"number":41,"title":"test
title","user":{"login":"meetmangukiya","id":7620533,"avatar_url":"https://avatars3.githubusercontent.com/u/7620533?v=3","gravatar_id":"","url":"https://api.github.com/users/meetmangukiya","html_url":"https://github.com/meetmangukiya","followers_url":"https://api.github.com/users/meetmangukiya/followers","following_url":"https://api.github.com/users/meetmangukiya/following{/other_user}","gists_url":"https://api.github.com/users/meetmangukiya/gists{/gist_id}","starred_url":"https://api.github.com/users/meetmangukiya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meetmangukiya/subscriptions","organizations_url":"https://api.github.com/users/meetmangukiya/orgs","repos_url":"https://api.github.com/users/meetmangukiya/repos","events_url":"https://api.github.com/users/meetmangukiya/events{/privacy}","received_events_url":"https://api.github.com/users/meetmangukiya/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"meetmangukiya","id":7620533,"avatar_url":"https://avatars3.githubusercontent.com/u/7620533?v=3","gravatar_id":"","url":"https://api.github.com/users/meetmangukiya","html_url":"https://github.com/meetmangukiya","followers_url":"https://api.github.com/users/meetmangukiya/followers","following_url":"https://api.github.com/users/meetmangukiya/following{/other_user}","gists_url":"https://api.github.com/users/meetmangukiya/gists{/gist_id}","starred_url":"https://api.github.com/users/meetmangukiya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meetmangukiya/subscriptions","organizations_url":"https://api.github.com/users/meetmangukiya/orgs","repos_url":"https://api.github.com/users/meetmangukiya/repos","events_url":"https://api.github.com/users/meetmangukiya/events{/privacy}","received_events_url":"https://api.github.com/users/meetmangukiya/received_events","type":"User","site_admin":false},"assignees":[{"login":"meetmangukiya","id":7620533,"avatar_url":"https://avatars3.githubusercontent.com/u/7620533?v=3","gravatar_id":"","url":"https://api.github.com/users/meetmangukiya","html_url":"https://github.com/meetmangukiya","followers_url":"https://api.github.com/users/meetmangukiya/followers","following_url":"https://api.github.com/users/meetmangukiya/following{/other_user}","gists_url":"https://api.github.com/users/meetmangukiya/gists{/gist_id}","starred_url":"https://api.github.com/users/meetmangukiya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meetmangukiya/subscriptions","organizations_url":"https://api.github.com/users/meetmangukiya/orgs","repos_url":"https://api.github.com/users/meetmangukiya/repos","events_url":"https://api.github.com/users/meetmangukiya/events{/privacy}","received_events_url":"https://api.github.com/users/meetmangukiya/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2017-06-06T10:22:34Z","updated_at":"2017-06-12T19:45:40Z","closed_at":null,"body":"test
body"}'}
headers:
Access-Control-Allow-Origin: ['*']
Access-Control-Expose-Headers: ['ETag, Link, 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-Length: ['3532']
Content-Security-Policy: [default-src 'none']
Content-Type: [application/json; charset=utf-8]
Date: ['Mon, 12 Jun 2017 19:45:40 GMT']
ETag: ['"39cd2c8924deebe9fbdb133876d6e075"']
Location: ['https://api.github.com/repos/gitmate-test-user/test/issues/41']
Server: [GitHub.com]
Status: [201 Created]
Strict-Transport-Security: [max-age=31536000; includeSubdomains; preload]
Vary: ['Accept, Authorization, Cookie, X-GitHub-OTP', Accept-Encoding]
X-Accepted-OAuth-Scopes: ['public_repo, repo']
X-Content-Type-Options: [nosniff]
X-Frame-Options: [deny]
X-GitHub-Media-Type: [github.v3; format=json]
X-GitHub-Request-Id: ['91CE:1B58E:3A6F573:4BE0BC5:593EEF64']
X-OAuth-Scopes: ['admin:gpg_key, admin:org, admin:org_hook, admin:public_key,
admin:repo_hook, delete_repo, gist, notifications, repo, user']
X-RateLimit-Limit: ['5000']
X-RateLimit-Remaining: ['4960']
X-RateLimit-Reset: ['1497297359']
X-Runtime-rack: ['0.176769']
X-Served-By: [62cdcc2d03a2f173f1c58590d1a90077]
X-XSS-Protection: [1; mode=block]
status: {code: 201, message: Created}
version: 1
......@@ -30,8 +30,13 @@ class GitHubIssueTest(unittest.TestCase):
self.assertEqual(self.iss.url,
'https://github.com/gitmate-test-user/test/issues/39')
@my_vcr.use_cassette('tests/GitHub/cassettes/github_issue_assignee.yaml')
def test_assignee(self):
self.assertEqual(self.iss.assignee, None)
iss = GitHubIssue(os.environ.get('GITHUB_TEST_TOKEN', ''),
'gitmate-test-user/test', 41)
iss.assignee = 'meetmangukiya'
self.assertEqual(iss.assignee, 'meetmangukiya')
def test_number(self):
self.assertEqual(self.iss.number, 39)
......
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [python-requests/2.17.3]
method: GET
uri: https://gitlab.com/api/v4/projects/gitmate-test-user%2Ftest/issues/27?User-Agent=IGitt
response:
body: {string: '{"id":5685687,"iid":27,"project_id":3439658,"title":"test issue","description":"","state":"opened","created_at":"2017-06-12T18:14:54.571Z","updated_at":"2017-06-12T18:41:11.033Z","labels":[],"milestone":null,"assignees":[],"author":{"name":"Meet
Mangukiya","username":"meetmangukiya","id":707601,"state":"active","avatar_url":"https://gitlab.com/uploads/system/user/avatar/707601/avatar.png","web_url":"https://gitlab.com/meetmangukiya"},"assignee":null,"user_notes_count":0,"upvotes":0,"downvotes":0,"due_date":null,"confidential":false,"weight":null,"web_url":"https://gitlab.com/gitmate-test-user/test/issues/27","subscribed":true}'}
headers:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Length: ['634']
Content-Type: [application/json]
Date: ['Mon, 12 Jun 2017 19:54:46 GMT']
Etag: [W/"6e93a25fa4396d90b684686707c4aed3"]
Server: [nginx]
Strict-Transport-Security: [max-age=31536000]
Vary: [Origin]
X-Frame-Options: [SAMEORIGIN]
X-Request-Id: [36ce2850-2ac2-466d-b937-b4811abaf4ec]
X-Runtime: ['0.349949']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [python-requests/2.17.3]
method: GET
uri: https://gitlab.com/api/v4/users?User-Agent=IGitt&username=meetmangukiya
response:
body: {string: '[{"name":"Meet Mangukiya","username":"meetmangukiya","id":707601,"state":"active","avatar_url":"https://gitlab.com/uploads/system/user/avatar/707601/avatar.png","web_url":"https://gitlab.com/meetmangukiya"}]'}
headers:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Length: ['207']
Content-Type: [application/json]
Date: ['Mon, 12 Jun 2017 19:54:53 GMT']
Etag: [W/"dba9fcc1837dc5610687047d786f3314"]
Link: ['<https://gitlab.com/api/v4/users?User-Agent=IGitt&active=false&blocked=false&external=false&page=1&per_page=20&private_token=&skip_ldap=false&username=meetmangukiya>;
rel="first", <https://gitlab.com/api/v4/users?User-Agent=IGitt&active=false&blocked=false&external=false&page=1&per_page=20&private_token=&skip_ldap=false&username=meetmangukiya>;
rel="last"']
Server: [nginx]
Strict-Transport-Security: [max-age=31536000]
Vary: [Origin]
X-Frame-Options: [SAMEORIGIN]
X-Next-Page: ['']
X-Page: ['1']
X-Per-Page: ['20']
X-Prev-Page: ['']
X-Request-Id: [6080996e-2593-43f8-bcd2-22d55fb4b67e]
X-Runtime: ['0.103986']
X-Total: ['1']
X-Total-Pages: ['1']
status: {code: 200, message: OK}
- request:
body: '{"assignee_ids": 707601}'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['24']
Content-Type: [application/json]
User-Agent: [python-requests/2.17.3]
method: PUT
uri: https://gitlab.com/api/v4/projects/gitmate-test-user%2Ftest/issues/27?User-Agent=IGitt
response:
body: {string: '{"id":5685687,"iid":27,"project_id":3439658,"title":"test issue","description":"","state":"opened","created_at":"2017-06-12T18:14:54.571Z","updated_at":"2017-06-12T19:55:03.051Z","labels":[],"milestone":null,"assignees":[{"name":"Meet
Mangukiya","username":"meetmangukiya","id":707601,"state":"active","avatar_url":"https://gitlab.com/uploads/system/user/avatar/707601/avatar.png","web_url":"https://gitlab.com/meetmangukiya"}],"author":{"name":"Meet
Mangukiya","username":"meetmangukiya","id":707601,"state":"active","avatar_url":"https://gitlab.com/uploads/system/user/avatar/707601/avatar.png","web_url":"https://gitlab.com/meetmangukiya"},"assignee":{"name":"Meet
Mangukiya","username":"meetmangukiya","id":707601,"state":"active","avatar_url":"https://gitlab.com/uploads/system/user/avatar/707601/avatar.png","web_url":"https://gitlab.com/meetmangukiya"},"user_notes_count":0,"upvotes":0,"downvotes":0,"due_date":null,"confidential":false,"weight":null,"web_url":"https://gitlab.com/gitmate-test-user/test/issues/27","subscribed":true}'}
headers:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Length: ['1040']
Content-Type: [application/json]
Date: ['Mon, 12 Jun 2017 19:55:03 GMT']
Etag: [W/"751afed878653015834545dc96cac866"]
Server: [nginx]
Strict-Transport-Security: [max-age=31536000]
Vary: [Origin]
X-Frame-Options: [SAMEORIGIN]
X-Request-Id: [4224d9ed-8dbc-4e22-85e7-16d9e8cee6e2]
X-Runtime: ['1.284307']
status: {code: 200, message: OK}
version: 1
......@@ -30,8 +30,14 @@ class GitLabIssueTest(unittest.TestCase):
self.assertEqual(self.iss.url,
'https://gitlab.com/gitmate-test-user/test/issues/3')
@my_vcr.use_cassette('tests/GitLab/cassettes/gitlab_issue_assignee.yaml')
def test_assignee(self):
self.assertIsNone(self.iss.assignee)
iss = GitLabIssue(os.environ.get('GITLAB_TEST_TOKEN', ''),
'gitmate-test-user/test', 27)
self.assertEqual(iss.assignee, None)
iss.assignee = 'meetmangukiya'
self.assertEqual(iss.assignee, 'meetmangukiya')
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