Skip to content

Commit b77f661

Browse files
committed
Add integration test for create_issue w/ assignees
There was not an integration test for this code path. Testing this path uncovered a bug in ShortUser when attempting to repr such objects. The name attribute is not available in the short object, so that object should print differently. The argument order for create_issue in github.py needed to match that of create_issue in repo.py, since it just passes through to that function. Signed-off-by: Jesse Keating <jkeating@j2solutions.net>
1 parent 3deb1e5 commit b77f661

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

github3/github.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def create_gist(self, description, files, public=True):
253253

254254
@requires_auth
255255
def create_issue(self, owner, repository, title, body=None, assignee=None,
256-
assignees=None, milestone=None, labels=[]):
256+
milestone=None, labels=[], assignees=None):
257257
"""Create an issue on the project 'repository' owned by 'owner'
258258
with title 'title'.
259259
@@ -289,8 +289,8 @@ def create_issue(self, owner, repository, title, body=None, assignee=None,
289289
repo = self.repository(owner, repository)
290290

291291
if repo is not None:
292-
return repo.create_issue(title, body, assignee, assignees,
293-
milestone, labels)
292+
return repo.create_issue(title, body, assignee, milestone,
293+
labels, assignees)
294294

295295
return self._instance_or_null(Issue, None)
296296

github3/users.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ class ShortUser(_User):
510510
.. versionadded:: 1.0.0
511511
"""
512512

513-
pass
513+
def _repr(self):
514+
return '<User [{s.login}]>'.format(s=self)
514515

515516

516517
class User(_User):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": "github3.py/1.0.0a4", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.drax-preview+json", "Connection": "keep-alive", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/github3py/fork_this"}, "response": {"body": {"encoding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KPpEvFU8Guqjh/adQCngstFW1sLjO+bbtlw0pdpflVFGFBSYWqBhyJfcoti/ny/ub+evt4unX/P79HGePjz8DZm2yScyP24htnj+NZ+nEJu/kkzTmmJEcyTyg0SQHoPv4gk9//913ENPQA08QMYUA+iPAZL6x8kYIkCyEk54FCWXfWt7fDedh0G9QlWiQV2QpDXigZqydzzfT+74TLU1rDufJTtuUWziTh2W+rqgJyi4WfpITVKrW+rhsNJo9Y/IrBmvDZlhJLiTb3ICpJrl0J35Jit8fIHkKbVWYRTj9Q95DFOV0EGqRtRBoV7rFwSJzERtDrv2/VcKxpF4kkKw37Hbfi7WvC3t0pfK8LeKG4upEbxH6Aq7pukBzZBCV+v3T57Vb4mSjn9Gs4vwVbul+bfl8BGXyXsx/8YtQWkqE6ZvtKB7ZIoZzx2+51jDiO97jtWPKM9P/L7nWNMpKyqgyRAMUX75HKsWdkfj5yFVjTuSsPrw8R8eYY8VuRYAAA==", "string": ""}, "headers": {"Date": "Tue, 19 Dec 2017 20:00:22 GMT", "Content-Type": "application/json; charset=utf-8", "Transfer-Encoding": "chunked", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4995", "X-RateLimit-Reset": "1513715907", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "ETag": "W/\"e403662f367bf0145983debb8fe265e0\"", "Last-Modified": "Sat, 16 Dec 2017 00:02:09 GMT", "X-OAuth-Scopes": "admin:org, delete_repo, repo", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "github.v3; param=drax-preview; format=json", "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", "Access-Control-Allow-Origin": "*", "Content-Security-Policy": "default-src 'none'", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Content-Type-Options": "nosniff", "X-Frame-Options": "deny", "X-XSS-Protection": "1; mode=block", "X-Runtime-rack": "0.072790", "Content-Encoding": "gzip", "X-GitHub-Request-Id": "E623:5EA3:191DBA:22A3B9:5A396FD6"}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/github3py/fork_this"}, "recorded_at": "2017-12-19T20:00:22"}, {"request": {"body": {"encoding": "utf-8", "string": "{\"title\": \"Test issue creation assignees\", \"body\": \"Let's see how well this works with Betamax\", \"labels\": [], \"assignees\": [\"omgjlk\", \"sigmavirus24\"]}"}, "headers": {"User-Agent": "github3.py/1.0.0a4", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "Connection": "keep-alive", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>", "Content-Length": "151"}, "method": "POST", "uri": "https://api.github.com/repos/github3py/fork_this/issues"}, "response": {"body": {"encoding": "utf-8", "string": "{\"url\":\"https://api.github.com/repos/github3py/fork_this/issues/13\",\"repository_url\":\"https://api.github.com/repos/github3py/fork_this\",\"labels_url\":\"https://api.github.com/repos/github3py/fork_this/issues/13/labels{/name}\",\"comments_url\":\"https://api.github.com/repos/github3py/fork_this/issues/13/comments\",\"events_url\":\"https://api.github.com/repos/github3py/fork_this/issues/13/events\",\"html_url\":\"https://github.com/github3py/fork_this/issues/13\",\"id\":283352004,\"number\":13,\"title\":\"Test issue creation assignees\",\"user\":{\"login\":\"omgjlk\",\"id\":523287,\"avatar_url\":\"https://avatars2.githubusercontent.com/u/523287?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/omgjlk\",\"html_url\":\"https://github.com/omgjlk\",\"followers_url\":\"https://api.github.com/users/omgjlk/followers\",\"following_url\":\"https://api.github.com/users/omgjlk/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/omgjlk/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/omgjlk/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/omgjlk/subscriptions\",\"organizations_url\":\"https://api.github.com/users/omgjlk/orgs\",\"repos_url\":\"https://api.github.com/users/omgjlk/repos\",\"events_url\":\"https://api.github.com/users/omgjlk/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/omgjlk/received_events\",\"type\":\"User\",\"site_admin\":false},\"labels\":[],\"state\":\"open\",\"locked\":false,\"assignee\":{\"login\":\"omgjlk\",\"id\":523287,\"avatar_url\":\"https://avatars2.githubusercontent.com/u/523287?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/omgjlk\",\"html_url\":\"https://github.com/omgjlk\",\"followers_url\":\"https://api.github.com/users/omgjlk/followers\",\"following_url\":\"https://api.github.com/users/omgjlk/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/omgjlk/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/omgjlk/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/omgjlk/subscriptions\",\"organizations_url\":\"https://api.github.com/users/omgjlk/orgs\",\"repos_url\":\"https://api.github.com/users/omgjlk/repos\",\"events_url\":\"https://api.github.com/users/omgjlk/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/omgjlk/received_events\",\"type\":\"User\",\"site_admin\":false},\"assignees\":[{\"login\":\"omgjlk\",\"id\":523287,\"avatar_url\":\"https://avatars2.githubusercontent.com/u/523287?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/omgjlk\",\"html_url\":\"https://github.com/omgjlk\",\"followers_url\":\"https://api.github.com/users/omgjlk/followers\",\"following_url\":\"https://api.github.com/users/omgjlk/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/omgjlk/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/omgjlk/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/omgjlk/subscriptions\",\"organizations_url\":\"https://api.github.com/users/omgjlk/orgs\",\"repos_url\":\"https://api.github.com/users/omgjlk/repos\",\"events_url\":\"https://api.github.com/users/omgjlk/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/omgjlk/received_events\",\"type\":\"User\",\"site_admin\":false},{\"login\":\"sigmavirus24\",\"id\":240830,\"avatar_url\":\"https://avatars3.githubusercontent.com/u/240830?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/sigmavirus24\",\"html_url\":\"https://github.com/sigmavirus24\",\"followers_url\":\"https://api.github.com/users/sigmavirus24/followers\",\"following_url\":\"https://api.github.com/users/sigmavirus24/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/sigmavirus24/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/sigmavirus24/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/sigmavirus24/subscriptions\",\"organizations_url\":\"https://api.github.com/users/sigmavirus24/orgs\",\"repos_url\":\"https://api.github.com/users/sigmavirus24/repos\",\"events_url\":\"https://api.github.com/users/sigmavirus24/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/sigmavirus24/received_events\",\"type\":\"User\",\"site_admin\":false}],\"milestone\":null,\"comments\":0,\"created_at\":\"2017-12-19T20:00:22Z\",\"updated_at\":\"2017-12-19T20:00:22Z\",\"closed_at\":null,\"author_association\":\"OWNER\",\"body_html\":\"<p>Let's see how well this works with Betamax</p>\",\"body_text\":\"Let's see how well this works with Betamax\",\"body\":\"Let's see how well this works with Betamax\",\"closed_by\":null}"}, "headers": {"Date": "Tue, 19 Dec 2017 20:00:22 GMT", "Content-Type": "application/json; charset=utf-8", "Content-Length": "4395", "Server": "GitHub.com", "Status": "201 Created", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4994", "X-RateLimit-Reset": "1513715907", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "ETag": "\"a70cf8c4d841713732253be31c4ed52f\"", "X-OAuth-Scopes": "admin:org, delete_repo, repo", "X-Accepted-OAuth-Scopes": "", "Location": "https://api.github.com/repos/github3py/fork_this/issues/13", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "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", "Access-Control-Allow-Origin": "*", "Content-Security-Policy": "default-src 'none'", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Content-Type-Options": "nosniff", "X-Frame-Options": "deny", "X-XSS-Protection": "1; mode=block", "X-Runtime-rack": "0.457169", "X-GitHub-Request-Id": "E623:5EA3:191DC1:22A3C0:5A396FD6"}, "status": {"code": 201, "message": "Created"}, "url": "https://api.github.com/repos/github3py/fork_this/issues"}, "recorded_at": "2017-12-19T20:00:22"}], "recorded_with": "betamax/0.8.0"}

tests/integration/test_github.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ def test_create_issue(self):
7474
assert i.title == 'Test issue creation'
7575
assert i.body == "Let's see how well this works with Betamax"
7676

77+
def test_create_issue_multiple_assignees(self):
78+
"""
79+
Test the ability of a GitHub instance to create a new issue.
80+
with multipole assignees
81+
"""
82+
self.auto_login()
83+
cassette_name = self.cassette_name('create_issue_assignees')
84+
with self.recorder.use_cassette(cassette_name):
85+
i = self.gh.create_issue(
86+
'github3py', 'fork_this', 'Test issue creation assignees',
87+
"Let's see how well this works with Betamax",
88+
assignees=['omgjlk', 'sigmavirus24']
89+
)
90+
91+
assert isinstance(i, github3.issues.Issue)
92+
assert i.title == 'Test issue creation assignees'
93+
assert i.body == "Let's see how well this works with Betamax"
94+
assert ['omgjlk', 'sigmavirus24'] == [a.login for a in i.assignees]
95+
7796
def test_create_key(self):
7897
"""Test the ability to create a key and delete it."""
7998
self.basic_login()

0 commit comments

Comments
 (0)