mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Allow GithubObject.update() to be passed headers (#1300)
SourceImport.update() is really GithubObject.update(), which just calls GET on the object's URL. Refetching a source import requires an additional header, so change GithubObject.update() to pass any it is given, and add a test for SourceImport.update() Fixes #1297
This commit is contained in:
@@ -279,7 +279,7 @@ class CompletableGithubObject(GithubObject):
|
||||
self._storeAndUseAttributes(headers, data)
|
||||
self.__completed = True
|
||||
|
||||
def update(self):
|
||||
def update(self, additional_headers=None):
|
||||
'''
|
||||
Check and update the object with conditional request
|
||||
:rtype: Boolean value indicating whether the object is changed
|
||||
@@ -289,6 +289,8 @@ class CompletableGithubObject(GithubObject):
|
||||
conditionalRequestHeader[Consts.REQ_IF_NONE_MATCH] = self.etag
|
||||
if self.last_modified is not None:
|
||||
conditionalRequestHeader[Consts.REQ_IF_MODIFIED_SINCE] = self.last_modified
|
||||
if additional_headers is not None:
|
||||
conditionalRequestHeader.update(additional_headers)
|
||||
|
||||
status, responseHeaders, output = self._requester.requestJson(
|
||||
"GET",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
################################################################################
|
||||
|
||||
from __future__ import absolute_import
|
||||
from github import Consts
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
@@ -143,6 +144,10 @@ class SourceImport(github.GithubObject.CompletableGithubObject):
|
||||
self._completeIfNotSet(self._vcs_url)
|
||||
return self._vcs_url.value
|
||||
|
||||
def update(self):
|
||||
import_header = {"Accept": Consts.mediaTypeImportPreview}
|
||||
return super(SourceImport, self).update(additional_headers=import_header)
|
||||
|
||||
def _initAttributes(self):
|
||||
self._authors_count = github.GithubObject.NotSet
|
||||
self._authors_url = github.GithubObject.NotSet
|
||||
|
||||
Reference in New Issue
Block a user