mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Added "assignees" argument in Repository.create_issue()
This commit is contained in:
@@ -75,6 +75,7 @@ import github.Stargazer
|
||||
atLeastPython26 = sys.hexversion >= 0x02060000
|
||||
atLeastPython3 = sys.hexversion >= 0x03000000
|
||||
|
||||
|
||||
class Repository(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Repositories. The reference can be found here http://developer.github.com/v3/repos/
|
||||
@@ -856,12 +857,13 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.Hook.Hook(self._requester, headers, data, completed=True)
|
||||
|
||||
def create_issue(self, title, body=github.GithubObject.NotSet, assignee=github.GithubObject.NotSet, milestone=github.GithubObject.NotSet, labels=github.GithubObject.NotSet):
|
||||
def create_issue(self, title, body=github.GithubObject.NotSet, assignee=github.GithubObject.NotSet, milestone=github.GithubObject.NotSet, labels=github.GithubObject.NotSet, assignees=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `POST /repos/:owner/:repo/issues <http://developer.github.com/v3/issues>`_
|
||||
:param title: string
|
||||
:param body: string
|
||||
:param assignee: string or :class:`github.NamedUser.NamedUser`
|
||||
:param assignees: list (of string or :class:`github.NamedUser.NamedUser`)
|
||||
:param milestone: :class:`github.Milestone.Milestone`
|
||||
:param labels: list of :class:`github.Label.Label`
|
||||
:rtype: :class:`github.Issue.Issue`
|
||||
@@ -869,6 +871,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
assert isinstance(title, (str, unicode)), title
|
||||
assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body
|
||||
assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee
|
||||
assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, unicode)) for element in assignees), assignees
|
||||
assert milestone is github.GithubObject.NotSet or isinstance(milestone, github.Milestone.Milestone), milestone
|
||||
assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) or isinstance(element, (str, unicode)) for element in labels), labels
|
||||
|
||||
@@ -882,6 +885,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
post_parameters["assignee"] = assignee
|
||||
else:
|
||||
post_parameters["assignee"] = assignee._identity
|
||||
if assignees is not github.GithubObject.NotSet:
|
||||
post_parameters["assignees"] = [element._identity if isinstance(element, github.NamedUser.NamedUser) else element for element in assignees]
|
||||
if milestone is not github.GithubObject.NotSet:
|
||||
post_parameters["milestone"] = milestone._identity
|
||||
if labels is not github.GithubObject.NotSet:
|
||||
|
||||
@@ -37,8 +37,8 @@ api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues
|
||||
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
{"body": "Body created by PyGithub", "assignee": "jacquev6", "labels": ["Question"], "milestone": 2, "title": "Issue also created by PyGithub"}
|
||||
{"body": "Body created by PyGithub", "assignee": "jacquev6", "assignees": ["jacquev6", "stuglaser"], "labels": ["Question"], "milestone": 2, "title": "Issue also created by PyGithub"}
|
||||
201
|
||||
[('status', '201 Created'), ('x-ratelimit-remaining', '4943'), ('content-length', '2069'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d131a11b793937127bf7d0ce56e2805e"'), ('date', 'Sun, 27 May 2012 05:40:15 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/issues/30')]
|
||||
{"updated_at":"2012-05-27T05:40:15Z","body":"Body created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/30","comments":0,"milestone":{"creator":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/2","number":2,"title":"Version 1.0: coherent public interface","due_on":"2012-06-04T07:00:00Z","open_issues":10,"created_at":"2012-03-08T12:22:28Z","state":"open","description":"Heavy rewrite to have:\r\n* a fully coherent public interface\r\n* usable stack-traces in case of exception\r\n* more explicit exceptions\r\n* more readable code (for library exploration, auto-completion in IDEs, etc.)\r\n\r\nSee working branch https://github.com/jacquev6/PyGithub/tree/topic/RewriteWithGeneratedCode","id":93547,"closed_issues":2},"number":30,"closed_by":null,"assignee":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"closed_at":null,"title":"Issue also created by PyGithub","labels":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}],"created_at":"2012-05-27T05:40:15Z","state":"open","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"id":4769659,"pull_request":{"patch_url":null,"diff_url":null,"html_url":null},"html_url":"https://github.com/jacquev6/PyGithub/issues/30"}
|
||||
{"updated_at":"2012-05-27T05:40:15Z","body":"Body created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/30","comments":0,"milestone":{"creator":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/2","number":2,"title":"Version 1.0: coherent public interface","due_on":"2012-06-04T07:00:00Z","open_issues":10,"created_at":"2012-03-08T12:22:28Z","state":"open","description":"Heavy rewrite to have:\r\n* a fully coherent public interface\r\n* usable stack-traces in case of exception\r\n* more explicit exceptions\r\n* more readable code (for library exploration, auto-completion in IDEs, etc.)\r\n\r\nSee working branch https://github.com/jacquev6/PyGithub/tree/topic/RewriteWithGeneratedCode","id":93547,"closed_issues":2},"number":30,"closed_by":null,"assignee":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"assignees":[{"url":"https://api.github.com/users/stuglaser","gravatar_id":"","login":"stuglaser","avatar_url":"https://avatars.githubusercontent.com/u/1527117?v=3","id":1527117},{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146}],"closed_at":null,"title":"Issue also created by PyGithub","labels":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}],"created_at":"2012-05-27T05:40:15Z","state":"open","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"id":4769659,"pull_request":{"patch_url":null,"diff_url":null,"html_url":null},"html_url":"https://github.com/jacquev6/PyGithub/issues/30"}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues
|
||||
{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
{"body": "Body created by PyGithub", "assignee": "jacquev6", "labels": ["Question"], "milestone": 2, "title": "Issue also created by PyGithub"}
|
||||
{"body": "Body created by PyGithub", "assignee": "jacquev6", "assignees": ["jacquev6", "stuglaser"], "labels": ["Question"], "milestone": 2, "title": "Issue also created by PyGithub"}
|
||||
201
|
||||
[('status', '201 Created'), ('x-ratelimit-remaining', '4943'), ('content-length', '2069'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d131a11b793937127bf7d0ce56e2805e"'), ('date', 'Sun, 27 May 2012 05:40:15 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/issues/30')]
|
||||
{"updated_at":"2012-05-27T05:40:15Z","body":"Body created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/30","comments":0,"milestone":{"creator":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/2","number":2,"title":"Version 1.0: coherent public interface","due_on":"2012-06-04T07:00:00Z","open_issues":10,"created_at":"2012-03-08T12:22:28Z","state":"open","description":"Heavy rewrite to have:\r\n* a fully coherent public interface\r\n* usable stack-traces in case of exception\r\n* more explicit exceptions\r\n* more readable code (for library exploration, auto-completion in IDEs, etc.)\r\n\r\nSee working branch https://github.com/jacquev6/PyGithub/tree/topic/RewriteWithGeneratedCode","id":93547,"closed_issues":2},"number":30,"closed_by":null,"assignee":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"closed_at":null,"title":"Issue also created by PyGithub","labels":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}],"created_at":"2012-05-27T05:40:15Z","state":"open","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"id":4769659,"pull_request":{"patch_url":null,"diff_url":null,"html_url":null},"html_url":"https://github.com/jacquev6/PyGithub/issues/30"}
|
||||
{"updated_at":"2012-05-27T05:40:15Z","body":"Body created by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/issues/30","comments":0,"milestone":{"creator":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/2","number":2,"title":"Version 1.0: coherent public interface","due_on":"2012-06-04T07:00:00Z","open_issues":10,"created_at":"2012-03-08T12:22:28Z","state":"open","description":"Heavy rewrite to have:\r\n* a fully coherent public interface\r\n* usable stack-traces in case of exception\r\n* more explicit exceptions\r\n* more readable code (for library exploration, auto-completion in IDEs, etc.)\r\n\r\nSee working branch https://github.com/jacquev6/PyGithub/tree/topic/RewriteWithGeneratedCode","id":93547,"closed_issues":2},"number":30,"closed_by":null,"assignee":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"assignees":[{"url":"https://api.github.com/users/stuglaser","gravatar_id":"","login":"stuglaser","avatar_url":"https://avatars.githubusercontent.com/u/1527117?v=3","id":1527117},{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146}],"closed_at":null,"title":"Issue also created by PyGithub","labels":[{"url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Question","name":"Question","color":"02e10c"}],"created_at":"2012-05-27T05:40:15Z","state":"open","user":{"url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"id":4769659,"pull_request":{"patch_url":null,"diff_url":null,"html_url":null},"html_url":"https://github.com/jacquev6/PyGithub/issues/30"}
|
||||
|
||||
|
||||
@@ -198,13 +198,13 @@ class Repository(Framework.TestCase):
|
||||
user = self.g.get_user("jacquev6")
|
||||
milestone = self.repo.get_milestone(2)
|
||||
question = self.repo.get_label("Question")
|
||||
issue = self.repo.create_issue("Issue also created by PyGithub", "Body created by PyGithub", user, milestone, [question])
|
||||
issue = self.repo.create_issue("Issue also created by PyGithub", "Body created by PyGithub", user, milestone, [question], ["jacquev6", "stuglaser"])
|
||||
self.assertEqual(issue.number, 30)
|
||||
|
||||
def testCreateIssueWithAllArgumentsStringLabel(self):
|
||||
user = self.g.get_user("jacquev6")
|
||||
milestone = self.repo.get_milestone(2)
|
||||
issue = self.repo.create_issue("Issue also created by PyGithub", "Body created by PyGithub", user, milestone, ['Question'])
|
||||
issue = self.repo.create_issue("Issue also created by PyGithub", "Body created by PyGithub", user, milestone, ["Question"], ["jacquev6", "stuglaser"])
|
||||
self.assertEqual(issue.number, 30)
|
||||
|
||||
def testCreateLabel(self):
|
||||
|
||||
Reference in New Issue
Block a user