mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Improve coverage of AuthenticatedUser
This commit is contained in:
@@ -131,8 +131,7 @@
|
||||
{ "name": "private", "type": "bool" },
|
||||
{ "name": "has_issues", "type": "bool" },
|
||||
{ "name": "has_wiki", "type": "bool" },
|
||||
{ "name": "has_downloads", "type": "bool" },
|
||||
{ "name": "team_id", "type": "@todo" }
|
||||
{ "name": "has_downloads", "type": "bool" }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -650,14 +650,6 @@
|
||||
"name": "bool"
|
||||
},
|
||||
"name": "has_downloads"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"simple": true,
|
||||
"cardinality": "scalar",
|
||||
"name": "@todo"
|
||||
},
|
||||
"name": "team_id"
|
||||
}
|
||||
],
|
||||
"type": {
|
||||
|
||||
@@ -123,7 +123,7 @@ Orgs
|
||||
|
||||
Repos
|
||||
-----
|
||||
* `create_repo( name, [description, homepage, private, has_issues, has_wiki, has_downloads, team_id] )`: `Repository`
|
||||
* `create_repo( name, [description, homepage, private, has_issues, has_wiki, has_downloads] )`: `Repository`
|
||||
* `name`: string
|
||||
* `description`: string
|
||||
* `homepage`: string
|
||||
@@ -131,7 +131,6 @@ Repos
|
||||
* `has_issues`: bool
|
||||
* `has_wiki`: bool
|
||||
* `has_downloads`: bool
|
||||
* `team_id`
|
||||
* `get_repo( name )`: `Repository`
|
||||
* `name`: string
|
||||
* `get_repos( [type] )`: list of `Repository`
|
||||
|
||||
@@ -226,7 +226,7 @@ class AuthenticatedUser( object ):
|
||||
)
|
||||
return UserKey.UserKey( self.__requester, data, completion = NoCompletion )
|
||||
|
||||
def create_repo( self, name, description = DefaultValueForOptionalParameters, homepage = DefaultValueForOptionalParameters, private = DefaultValueForOptionalParameters, has_issues = DefaultValueForOptionalParameters, has_wiki = DefaultValueForOptionalParameters, has_downloads = DefaultValueForOptionalParameters, team_id = DefaultValueForOptionalParameters ):
|
||||
def create_repo( self, name, description = DefaultValueForOptionalParameters, homepage = DefaultValueForOptionalParameters, private = DefaultValueForOptionalParameters, has_issues = DefaultValueForOptionalParameters, has_wiki = DefaultValueForOptionalParameters, has_downloads = DefaultValueForOptionalParameters ):
|
||||
post_parameters = {
|
||||
"name": name,
|
||||
}
|
||||
@@ -242,8 +242,6 @@ class AuthenticatedUser( object ):
|
||||
post_parameters[ "has_wiki" ] = has_wiki
|
||||
if has_downloads is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "has_downloads" ] = has_downloads
|
||||
if team_id is not DefaultValueForOptionalParameters:
|
||||
post_parameters[ "team_id" ] = team_id
|
||||
status, headers, data = self.__requester.request(
|
||||
"POST",
|
||||
"https://api.github.com/user" + "/repos",
|
||||
|
||||
@@ -40,6 +40,11 @@ class Gist( Framework.TestCase ):
|
||||
self.assertEquals( gist.description, "Gist created by PyGithub" )
|
||||
self.assertEquals( gist.files, {u'foobar.txt': {u'raw_url': u'https://gist.github.com/raw/2729810/73a1c7f17aa0ad5d7cbb5a8ca033ce47d3d23197/foobar.txt', u'language': u'Text', u'filename': u'foobar.txt', u'content': u'File created by PyGithub', u'type': u'text/plain', u'size': 24}} ) ### @todo
|
||||
|
||||
def testCreateWithoutDescription( self ):
|
||||
gist = self.g.get_user().create_gist( True, { "foobar.txt": { "content": "File created by PyGithub" } } )
|
||||
self.assertEquals( gist.description, None )
|
||||
self.assertEquals( gist.files, {u'foobar.txt': {u'raw_url': u'https://gist.github.com/raw/2793179/73a1c7f17aa0ad5d7cbb5a8ca033ce47d3d23197/foobar.txt', u'language': u'Text', u'filename': u'foobar.txt', u'content': u'File created by PyGithub', u'type': u'text/plain', u'size': 24}} ) ### @todo
|
||||
|
||||
def testEditWithoutParameters( self ):
|
||||
gist = self.g.get_gist( "2729810" )
|
||||
gist.edit()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
POST /gists {'Authorization': 'Basic login_and_password_removed'} {"files": {"foobar.txt": {"content": "File created by PyGithub"}}, "public": true}
|
||||
201
|
||||
[('status', '201 Created'), ('x-ratelimit-remaining', '4981'), ('content-length', '1424'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"7abbb6858d17ad64e3d5874676725694"'), ('date', 'Sat, 26 May 2012 09:50:03 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/gists/2793179')]
|
||||
{"updated_at":"2012-05-26T09:50:02Z","url":"https://api.github.com/gists/2793179","comments":0,"public":true,"forks":[],"git_pull_url":"git://gist.github.com/2793179.git","files":{"foobar.txt":{"type":"text/plain","raw_url":"https://gist.github.com/raw/2793179/73a1c7f17aa0ad5d7cbb5a8ca033ce47d3d23197/foobar.txt","size":24,"filename":"foobar.txt","content":"File created by PyGithub","language":"Text"}},"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"},"description":null,"created_at":"2012-05-26T09:50:02Z","git_push_url":"git@gist.github.com:2793179.git","id":"2793179","history":[{"url":"https://api.github.com/gists/2793179/069e7c0041c34619b5aebf0e918536cb3bfeff9a","change_status":{"deletions":0,"additions":1,"total":1},"version":"069e7c0041c34619b5aebf0e918536cb3bfeff9a","committed_at":"2012-05-26T09:50:03Z","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"}}],"html_url":"https://gist.github.com/2793179"}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
POST /user/repos {'Authorization': 'Basic login_and_password_removed'} {"has_wiki": false, "name": "TestPyGithub", "has_downloads": false, "private": false, "has_issues": false, "homepage": "http://foobar.com", "description": "Repo created by PyGithub"}
|
||||
201
|
||||
[('status', '201 Created'), ('x-ratelimit-remaining', '4979'), ('content-length', '1111'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1c6473a60481c33b28a926041f763fce"'), ('date', 'Sat, 26 May 2012 09:55:27 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/TestPyGithub')]
|
||||
{"clone_url":"https://github.com/jacquev6/TestPyGithub.git","has_downloads":false,"watchers":1,"git_url":"git://github.com/jacquev6/TestPyGithub.git","updated_at":"2012-05-26T09:55:27Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://foobar.com","url":"https://api.github.com/repos/jacquev6/TestPyGithub","has_wiki":false,"has_issues":false,"fork":false,"forks":1,"mirror_url":null,"size":0,"private":false,"open_issues":0,"svn_url":"https://github.com/jacquev6/TestPyGithub","owner":{"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"},"name":"TestPyGithub","language":null,"description":"Repo created by PyGithub","ssh_url":"git@github.com:jacquev6/TestPyGithub.git","pushed_at":"2012-05-26T09:55:27Z","created_at":"2012-05-26T09:55:27Z","id":4454027,"html_url":"https://github.com/jacquev6/TestPyGithub","full_name":"jacquev6/TestPyGithub"}
|
||||
|
||||
@@ -46,6 +46,10 @@ class Repository( Framework.TestCase ):
|
||||
repo = self.user.create_repo( "TestPyGithub" )
|
||||
self.assertEqual( repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub" )
|
||||
|
||||
def testCreateWithAllArguments( self ):
|
||||
repo = self.user.create_repo( "TestPyGithub", "Repo created by PyGithub", "http://foobar.com", private = False, has_issues = False, has_wiki = False, has_downloads = False )
|
||||
self.assertEqual( repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub" )
|
||||
|
||||
def testEditWithoutArguments( self ):
|
||||
repo = self.user.get_repo( "TestPyGithub" )
|
||||
self.assertEqual( repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub" )
|
||||
|
||||
Reference in New Issue
Block a user