mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 03:11:09 +00:00
Test PullRequests
This commit is contained in:
@@ -147,6 +147,21 @@ class PullRequest( object ):
|
||||
self.__completeIfNeeded( self.__user )
|
||||
return self.__user
|
||||
|
||||
def create_comment( self, body, commit_id, path, position ):
|
||||
post_parameters = {
|
||||
"body": body,
|
||||
"commit_id": commit_id,
|
||||
"path": path,
|
||||
"position": position,
|
||||
}
|
||||
status, headers, data = self.__requester.request(
|
||||
"POST",
|
||||
str( self.url ) + "/comments",
|
||||
None,
|
||||
post_parameters
|
||||
)
|
||||
return PullRequestComment.PullRequestComment( self.__requester, data, completion = NoCompletion )
|
||||
|
||||
def edit( self, title = DefaultValueForOptionalParameters, body = DefaultValueForOptionalParameters, state = DefaultValueForOptionalParameters ):
|
||||
post_parameters = {
|
||||
}
|
||||
@@ -167,7 +182,7 @@ class PullRequest( object ):
|
||||
def get_comment( self, id ):
|
||||
status, headers, data = self.__requester.request(
|
||||
"GET",
|
||||
str( self.url ) + "/comments" + "/" + str( id ),
|
||||
"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/" + str( id ), ### @todo
|
||||
None,
|
||||
None
|
||||
)
|
||||
@@ -229,7 +244,7 @@ class PullRequest( object ):
|
||||
"PUT",
|
||||
str( self.url ) + "/merge",
|
||||
None,
|
||||
None
|
||||
{}
|
||||
)
|
||||
|
||||
def __initAttributes( self ):
|
||||
@@ -277,7 +292,7 @@ class PullRequest( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
# @todo Remove this debug weakness: we shall assume that github will add new attributes
|
||||
for attribute in attributes:
|
||||
assert attribute in [ "additions", "base", "body", "changed_files", "closed_at", "comments", "commits", "created_at", "deletions", "diff_url", "head", "html_url", "id", "issue_url", "mergeable", "merged", "merged_at", "merged_by", "number", "patch_url", "review_comments", "state", "title", "updated_at", "url", "user", ], attribute
|
||||
assert attribute in [ "additions", "base", "body", "changed_files", "closed_at", "comments", "commits", "created_at", "deletions", "diff_url", "head", "html_url", "id", "issue_url", "mergeable", "merged", "merged_at", "merged_by", "number", "patch_url", "review_comments", "state", "title", "updated_at", "url", "user", "_links", ], attribute
|
||||
# @todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "additions" in attributes and attributes[ "additions" ] is not None: # pragma no branch
|
||||
self.__additions = attributes[ "additions" ]
|
||||
|
||||
@@ -29,20 +29,20 @@ class PullRequestComment( object ):
|
||||
self.__completeIfNeeded( self.__created_at )
|
||||
return self.__created_at
|
||||
|
||||
@property
|
||||
def html_url( self ):
|
||||
self.__completeIfNeeded( self.__html_url )
|
||||
return self.__html_url
|
||||
|
||||
@property
|
||||
def id( self ):
|
||||
self.__completeIfNeeded( self.__id )
|
||||
return self.__id
|
||||
|
||||
@property
|
||||
def line( self ):
|
||||
self.__completeIfNeeded( self.__line )
|
||||
return self.__line
|
||||
def original_commit_id( self ):
|
||||
self.__completeIfNeeded( self.__original_commit_id )
|
||||
return self.__original_commit_id
|
||||
|
||||
@property
|
||||
def original_position( self ):
|
||||
self.__completeIfNeeded( self.__original_position )
|
||||
return self.__original_position
|
||||
|
||||
@property
|
||||
def path( self ):
|
||||
@@ -93,9 +93,9 @@ class PullRequestComment( object ):
|
||||
self.__body = None
|
||||
self.__commit_id = None
|
||||
self.__created_at = None
|
||||
self.__html_url = None
|
||||
self.__id = None
|
||||
self.__line = None
|
||||
self.__original_commit_id = None
|
||||
self.__original_position = None
|
||||
self.__path = None
|
||||
self.__position = None
|
||||
self.__updated_at = None
|
||||
@@ -119,7 +119,7 @@ class PullRequestComment( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
# @todo Remove this debug weakness: we shall assume that github will add new attributes
|
||||
for attribute in attributes:
|
||||
assert attribute in [ "body", "commit_id", "created_at", "html_url", "id", "line", "path", "position", "updated_at", "url", "user", ], attribute
|
||||
assert attribute in [ "body", "commit_id", "created_at", "id", "original_commit_id", "original_position", "path", "position", "updated_at", "url", "user", "_links", ], attribute
|
||||
# @todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "body" in attributes and attributes[ "body" ] is not None: # pragma no branch
|
||||
self.__body = attributes[ "body" ]
|
||||
@@ -127,12 +127,12 @@ class PullRequestComment( object ):
|
||||
self.__commit_id = attributes[ "commit_id" ]
|
||||
if "created_at" in attributes and attributes[ "created_at" ] is not None: # pragma no branch
|
||||
self.__created_at = attributes[ "created_at" ]
|
||||
if "html_url" in attributes and attributes[ "html_url" ] is not None: # pragma no branch
|
||||
self.__html_url = attributes[ "html_url" ]
|
||||
if "id" in attributes and attributes[ "id" ] is not None: # pragma no branch
|
||||
self.__id = attributes[ "id" ]
|
||||
if "line" in attributes and attributes[ "line" ] is not None: # pragma no branch
|
||||
self.__line = attributes[ "line" ]
|
||||
if "original_commit_id" in attributes and attributes[ "original_commit_id" ] is not None: # pragma no branch
|
||||
self.__original_commit_id = attributes[ "original_commit_id" ]
|
||||
if "original_position" in attributes and attributes[ "original_position" ] is not None: # pragma no branch
|
||||
self.__original_position = attributes[ "original_position" ]
|
||||
if "path" in attributes and attributes[ "path" ] is not None: # pragma no branch
|
||||
self.__path = attributes[ "path" ]
|
||||
if "position" in attributes and attributes[ "position" ] is not None: # pragma no branch
|
||||
|
||||
@@ -383,6 +383,28 @@ class Repository( object ):
|
||||
)
|
||||
return Milestone.Milestone( self.__requester, data, completion = NoCompletion )
|
||||
|
||||
def create_pull( self, *args, **kwds ):
|
||||
if len( args ) + len( kwds ) == 4:
|
||||
return self.__create_pull_1( *args, **kwds )
|
||||
else:
|
||||
return self.__create_pull_2( *args, **kwds )
|
||||
|
||||
def __create_pull_1( self, title, body, base, head ):
|
||||
return self.__create_pull( title = title, body = body, base = base, head = head )
|
||||
|
||||
def __create_pull_2( self, issue, base, head ):
|
||||
return self.__create_pull( issue = issue, base = base, head = head )
|
||||
|
||||
def __create_pull( self, **kwds ):
|
||||
post_parameters = kwds
|
||||
status, headers, data = self.__requester.request(
|
||||
"POST",
|
||||
str( self.url ) + "/pulls",
|
||||
None,
|
||||
post_parameters
|
||||
)
|
||||
return PullRequest.PullRequest( self.__requester, data, completion = NoCompletion )
|
||||
|
||||
def edit( self, name, description = DefaultValueForOptionalParameters, homepage = DefaultValueForOptionalParameters, public = DefaultValueForOptionalParameters, has_issues = DefaultValueForOptionalParameters, has_wiki = DefaultValueForOptionalParameters, has_downloads = DefaultValueForOptionalParameters ):
|
||||
post_parameters = {
|
||||
"name": name,
|
||||
|
||||
Reference in New Issue
Block a user