mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Merge remote-tracking branch 'origin/topic/DeleteRepository' into develop
This commit is contained in:
@@ -127,6 +127,7 @@ API `/repos/:user/:repo`
|
||||
========================
|
||||
* GET: `AuthenticatedUser.get_repo`, `NamedUser.get_repo` or `Organization.get_repo`
|
||||
* PATCH: `Repository.edit`
|
||||
* DELETE: `Repository.delete`
|
||||
|
||||
API `/repos/:user/:repo/branches`
|
||||
=================================
|
||||
|
||||
@@ -1076,6 +1076,10 @@ Attributes
|
||||
* `url`: string
|
||||
* `watchers`: integer
|
||||
|
||||
Deletion
|
||||
--------
|
||||
* `delete()`
|
||||
|
||||
Comparison
|
||||
----------
|
||||
* `compare( base, head )`: `Comparison`
|
||||
|
||||
@@ -458,6 +458,14 @@ class Repository( GithubObject.GithubObject ):
|
||||
)
|
||||
return PullRequest.PullRequest( self._requester, data, completed = True )
|
||||
|
||||
def delete( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"DELETE",
|
||||
self.url,
|
||||
None,
|
||||
None
|
||||
)
|
||||
|
||||
def edit( self, name, description = GithubObject.NotSet, homepage = GithubObject.NotSet, public = GithubObject.NotSet, has_issues = GithubObject.NotSet, has_wiki = GithubObject.NotSet, has_downloads = GithubObject.NotSet ):
|
||||
assert isinstance( name, ( str, unicode ) ), name
|
||||
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
|
||||
|
||||
+11
-3
@@ -24,6 +24,14 @@ except ImportError: #pragma no cover: only for Python 2.5
|
||||
import GithubException
|
||||
|
||||
class Requester:
|
||||
__httpConnectionClass = httplib.HTTPConnection
|
||||
__httpsConnectionClass = httplib.HTTPSConnection
|
||||
|
||||
@classmethod
|
||||
def injectConnectionClasses( cls, httpConnectionClass, httpsConnectionClass ):
|
||||
cls.__httpConnectionClass = httpConnectionClass
|
||||
cls.__httpsConnectionClass = httpsConnectionClass
|
||||
|
||||
def __init__( self, login_or_token, password, base_url ):
|
||||
if password is not None:
|
||||
login = login_or_token
|
||||
@@ -40,9 +48,9 @@ class Requester:
|
||||
self.__port = o.port
|
||||
self.__prefix = o.path
|
||||
if o.scheme == "https":
|
||||
self.__connection_class = httplib.HTTPSConnection
|
||||
self.__connectionClass = self.__httpsConnectionClass
|
||||
elif o.scheme == "http":
|
||||
self.__connection_class = httplib.HTTPConnection
|
||||
self.__connectionClass = self.__httpConnectionClass
|
||||
else:
|
||||
assert( False ) #pragma no cover
|
||||
|
||||
@@ -71,7 +79,7 @@ class Requester:
|
||||
if self.__authorizationHeader is not None:
|
||||
headers[ "Authorization" ] = self.__authorizationHeader
|
||||
|
||||
cnx = self.__connection_class( host = self.__hostname, port = self.__port, strict = True )
|
||||
cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True )
|
||||
cnx.request(
|
||||
verb,
|
||||
self.__completeUrl( url, parameters ),
|
||||
|
||||
+13
-8
@@ -77,14 +77,15 @@ class RecordingConnection:
|
||||
class RecordingHttpConnection( RecordingConnection ):
|
||||
_realConnection = httplib.HTTPConnection
|
||||
|
||||
def __init__( self, file, host, port, *args, **kwds ):
|
||||
RecordingConnection.__init__( self, file, "http", host, port, *args, **kwds )
|
||||
def __init__( self, file, *args, **kwds ):
|
||||
RecordingConnection.__init__( self, file, "http", *args, **kwds )
|
||||
|
||||
class RecordingHttpsConnection( RecordingConnection ):
|
||||
_realConnection = httplib.HTTPSConnection
|
||||
|
||||
def __init__( self, file, host, port, *args, **kwds ):
|
||||
RecordingConnection.__init__( self, file, "https", host, port, *args, **kwds )
|
||||
def __init__( self, file, *args, **kwds ):
|
||||
print args, kwds
|
||||
RecordingConnection.__init__( self, file, "https", *args, **kwds )
|
||||
|
||||
class ReplayingConnection:
|
||||
def __init__( self, testCase, file, protocol, host, port, *args, **kwds ):
|
||||
@@ -123,15 +124,19 @@ class BasicTestCase( unittest.TestCase ):
|
||||
self.__fileName = ""
|
||||
self.__file = None
|
||||
if self.recordMode:
|
||||
httplib.HTTPSConnection = lambda *args, **kwds: RecordingHttpsConnection( self.__openFile( "wb" ), *args, **kwds )
|
||||
httplib.HTTPConnection = lambda *args, **kwds: RecordingHttpConnection( self.__openFile( "wb" ), *args, **kwds )
|
||||
github.Requester.Requester.injectConnectionClasses(
|
||||
lambda ignored, *args, **kwds: RecordingHttpConnection( self.__openFile( "wb" ), *args, **kwds ),
|
||||
lambda ignored, *args, **kwds: RecordingHttpsConnection( self.__openFile( "wb" ), *args, **kwds )
|
||||
)
|
||||
import GithubCredentials
|
||||
self.login = GithubCredentials.login
|
||||
self.password = GithubCredentials.password
|
||||
self.oauth_token = GithubCredentials.oauth_token
|
||||
else:
|
||||
httplib.HTTPSConnection = lambda *args, **kwds: ReplayingHttpsConnection( self, self.__openFile( "r" ), *args, **kwds )
|
||||
httplib.HTTPConnection = lambda *args, **kwds: ReplayingHttpConnection( self, self.__openFile( "r" ), *args, **kwds )
|
||||
github.Requester.Requester.injectConnectionClasses(
|
||||
lambda ignored, *args, **kwds: ReplayingHttpConnection( self, self.__openFile( "r" ), *args, **kwds ),
|
||||
lambda ignored, *args, **kwds: ReplayingHttpsConnection( self, self.__openFile( "r" ), *args, **kwds )
|
||||
)
|
||||
self.login = "login"
|
||||
self.password = "password"
|
||||
self.oauth_token = "oauth_token"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
https GET api.github.com None /user {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('x-ratelimit-limit', '5000'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '806'), ('server', 'nginx/1.0.13'), ('last-modified', 'Tue, 14 Aug 2012 18:41:03 GMT'), ('connection', 'keep-alive'), ('etag', '"a16173bc016f1c15e3e635051c76c388"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Thu, 23 Aug 2012 07:30:50 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"private_gists":5,"plan":{"private_repos":5,"space":614400,"collaborators":1,"name":"micro"},"type":"User","public_repos":12,"followers":13,"following":28,"location":"Paris, France","hireable":false,"disk_usage":14544,"created_at":"2010-07-09T06:10:06Z","login":"jacquev6","bio":"","blog":"http://vincent-jacques.net","total_private_repos":5,"collaborators":0,"email":"vincent@vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","name":"Vincent Jacques","url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","owned_private_repos":5,"public_gists":3,"id":327146,"html_url":"https://github.com/jacquev6","company":"Criteo"}
|
||||
|
||||
https GET api.github.com None /repos/jacquev6/TestPyGithub {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('x-ratelimit-limit', '5000'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1176'), ('server', 'nginx/1.0.13'), ('last-modified', 'Thu, 23 Aug 2012 07:30:19 GMT'), ('connection', 'keep-alive'), ('etag', '"b997e723dda2e6baea587ef9b5b94e73"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Thu, 23 Aug 2012 07:30:51 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"clone_url":"https://github.com/jacquev6/TestPyGithub.git","git_url":"git://github.com/jacquev6/TestPyGithub.git","full_name":"jacquev6/TestPyGithub","open_issues":0,"has_issues":true,"owner":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","id":327146},"watchers_count":0,"homepage":null,"ssh_url":"git@github.com:jacquev6/TestPyGithub.git","master_branch":"master","open_issues_count":0,"language":null,"created_at":"2012-08-23T07:30:19Z","permissions":{"admin":true,"push":true,"pull":true},"mirror_url":null,"has_downloads":true,"description":null,"pushed_at":"2012-08-23T07:30:19Z","forks":0,"forks_count":0,"size":0,"fork":false,"svn_url":"https://github.com/jacquev6/TestPyGithub","updated_at":"2012-08-23T07:30:19Z","name":"TestPyGithub","url":"https://api.github.com/repos/jacquev6/TestPyGithub","network_count":0,"has_wiki":true,"private":false,"id":5520886,"watchers":0,"html_url":"https://github.com/jacquev6/TestPyGithub"}
|
||||
|
||||
https DELETE api.github.com None /repos/jacquev6/TestPyGithub {'Authorization': 'Basic login_and_password_removed'} null
|
||||
204
|
||||
[('status', '204 No Content'), ('x-ratelimit-remaining', '4985'), ('x-content-type-options', 'nosniff'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Thu, 23 Aug 2012 07:30:52 GMT')]
|
||||
|
||||
|
||||
@@ -64,6 +64,10 @@ class Repository( Framework.TestCase ):
|
||||
self.repo.edit( "PyGithub", "Python library implementing the full Github API v3" )
|
||||
self.assertEqual( self.repo.description, "Python library implementing the full Github API v3" )
|
||||
|
||||
def testDelete( self ):
|
||||
repo = self.g.get_user().get_repo( "TestPyGithub" )
|
||||
repo.delete()
|
||||
|
||||
def testGetContributors( self ):
|
||||
self.assertListKeyEqual( self.repo.get_contributors(), lambda c: ( c.login, c.contributions ), [ ( "jacquev6", 355 ) ] )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user