Test Download and CommitComment

This commit is contained in:
Vincent Jacques
2012-05-22 20:18:37 +01:00
parent 815720f0de
commit 473c92adcd
18 changed files with 174 additions and 15 deletions
@@ -333,7 +333,6 @@
{ "name": "body", "type": "@todo" }
],
"optionalParameters": [
{ "name": "commit_id", "type": "@todo" },
{ "name": "line", "type": "@todo" },
{ "name": "path", "type": "@todo" },
{ "name": "position", "type": "@todo" }
@@ -1793,14 +1793,6 @@
},
"isMutation": false,
"optionalParameters": [
{
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
},
"name": "commit_id"
},
{
"type": {
"simple": true,
+1 -2
View File
@@ -198,9 +198,8 @@ Attributes
Comments
--------
* `create_comment( body, [commit_id, line, path, position] )`: `CommitComment`
* `create_comment( body, [line, path, position] )`: `CommitComment`
* `body`
* `commit_id`
* `line`
* `path`
* `position`
+1 -3
View File
@@ -59,12 +59,10 @@ class Commit( object ):
self.__completeIfNeeded( self.__url )
return self.__url
def create_comment( self, body, commit_id = DefaultValueForOptionalParameters, line = DefaultValueForOptionalParameters, path = DefaultValueForOptionalParameters, position = DefaultValueForOptionalParameters ):
def create_comment( self, body, line = DefaultValueForOptionalParameters, path = DefaultValueForOptionalParameters, position = DefaultValueForOptionalParameters ):
post_parameters = {
"body": body,
}
if commit_id is not DefaultValueForOptionalParameters:
post_parameters[ "commit_id" ] = commit_id
if line is not DefaultValueForOptionalParameters:
post_parameters[ "line" ] = line
if path is not DefaultValueForOptionalParameters:
+1 -1
View File
@@ -160,7 +160,7 @@ class Download( 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 [ "accesskeyid", "acl", "bucket", "content_type", "created_at", "description", "download_count", "expirationdate", "html_url", "id", "mime_type", "name", "path", "policy", "prefix", "redirect", "s3_url", "signature", "size", "url", ], attribute
assert attribute in [ "accesskeyid", "acl", "bucket", "content_type", "created_at", "description", "download_count", "expirationdate", "html_url", "id", "mime_type", "name", "path", "policy", "prefix", "redirect", "s3_url", "signature", "size", "url", "x-amz-meta-content-disposition" ], attribute
# @todo No need to check if attribute is in attributes when attribute is mandatory
if "accesskeyid" in attributes and attributes[ "accesskeyid" ] is not None:
self.__accesskeyid = attributes[ "accesskeyid" ]
+56
View File
@@ -0,0 +1,56 @@
import Framework
class Download( Framework.TestCaseWithRepo ):
def testCreateWithMinimalArguments( self ):
download = self.repo.create_download( "Foobar.txt", 1024 )
self.assertEqual( download.id, 242562 )
def testCreateWithAllArguments( self ):
download = self.repo.create_download( "Foobar.txt", 1024, "Download created by PyGithub", "text/richtext" )
self.assertEqual( download.accesskeyid, "1DWESVTPGHQVTX38V182" )
self.assertEqual( download.acl, "public-read" )
self.assertEqual( download.bucket, "github" )
self.assertEqual( download.content_type, "text/richtext" )
self.assertEqual( download.created_at, "2012-05-22T19:11:49Z" )
self.assertEqual( download.description, "Download created by PyGithub" )
self.assertEqual( download.download_count, 0 )
self.assertEqual( download.expirationdate, "2112-05-22T19:11:49.000Z" )
self.assertEqual( download.html_url, "https://github.com/downloads/jacquev6/PyGithub/Foobar.txt" )
self.assertEqual( download.id, 242556 )
self.assertEqual( download.mime_type, "text/richtext" )
self.assertEqual( download.name, "Foobar.txt" )
self.assertEqual( download.path, "downloads/jacquev6/PyGithub/Foobar.txt" )
self.assertEqual( download.policy, "ewogICAgJ2V4cGlyYXRpb24nOiAnMjExMi0wNS0yMlQxOToxMTo0OS4wMDBaJywKICAgICdjb25kaXRpb25zJzogWwogICAgICAgIHsnYnVja2V0JzogJ2dpdGh1Yid9LAogICAgICAgIHsna2V5JzogJ2Rvd25sb2Fkcy9qYWNxdWV2Ni9QeUdpdGh1Yi9Gb29iYXIudHh0J30sCiAgICAgICAgeydhY2wnOiAncHVibGljLXJlYWQnfSwKICAgICAgICB7J3N1Y2Nlc3NfYWN0aW9uX3N0YXR1cyc6ICcyMDEnfSwKICAgICAgICBbJ3N0YXJ0cy13aXRoJywgJyRGaWxlbmFtZScsICcnXSwKICAgICAgICBbJ3N0YXJ0cy13aXRoJywgJyRDb250ZW50LVR5cGUnLCAnJ10KICAgIF0KfQ==" )
self.assertEqual( download.prefix, "downloads/jacquev6/PyGithub" )
self.assertEqual( download.redirect, False )
self.assertEqual( download.s3_url, "https://github.s3.amazonaws.com/" )
self.assertEqual( download.signature, "8FCU/4rgT3ohXfE9N6HO7JgbuK4=" )
self.assertEqual( download.size, 1024 )
self.assertEqual( download.url, "https://api.github.com/repos/jacquev6/PyGithub/downloads/242556" )
def testAttributes( self ):
download = self.repo.get_download( 242550 )
self.assertEqual( download.accesskeyid, None )
self.assertEqual( download.acl, None )
self.assertEqual( download.bucket, None )
self.assertEqual( download.content_type, "text/plain" )
self.assertEqual( download.created_at, "2012-05-22T18:58:32Z" )
self.assertEqual( download.description, None )
self.assertEqual( download.download_count, 0 )
self.assertEqual( download.expirationdate, None )
self.assertEqual( download.html_url, "https://github.com/downloads/jacquev6/PyGithub/Foobar.txt" )
self.assertEqual( download.id, 242550 )
self.assertEqual( download.mime_type, None )
self.assertEqual( download.name, "Foobar.txt" )
self.assertEqual( download.path, None )
self.assertEqual( download.policy, None )
self.assertEqual( download.prefix, None )
self.assertEqual( download.redirect, None )
self.assertEqual( download.s3_url, None )
self.assertEqual( download.signature, None )
self.assertEqual( download.size, 1024 )
self.assertEqual( download.url, "https://api.github.com/repos/jacquev6/PyGithub/downloads/242550" )
def testDelete( self ):
download = self.repo.get_download( 242562 )
download.delete()
+29
View File
@@ -42,6 +42,35 @@ class Branch( Framework.TestCaseWithRepo ):
self.assertEqual( comment.url, "https://api.github.com/repos/jacquev6/PyGithub/comments/1347033" )
self.assertEqual( comment.user.login, "bilderbuchi" )
def testCreateCommitComment( self ):
commit = self.repo.get_commit( "6945921c529be14c3a8f566dd1e483674516d46d" )
comment = commit.create_comment( "Comment created by PyGithub" )
self.assertEqual( comment.id, 1361949 )
def testCreateCommitCommentOnFileLine( self ):
commit = self.repo.get_commit( "6945921c529be14c3a8f566dd1e483674516d46d" )
comment = commit.create_comment( "Comment created by PyGithub", path = "codegen/templates/GithubObject.MethodBody.UseResult.py", line = 26 )
self.assertEqual( comment.id, 1362000 )
self.assertEqual( comment.line, 26 )
self.assertEqual( comment.path, "codegen/templates/GithubObject.MethodBody.UseResult.py" )
self.assertEqual( comment.position, None )
def testCreateCommitCommentOnFilePosition( self ):
commit = self.repo.get_commit( "6945921c529be14c3a8f566dd1e483674516d46d" )
comment = commit.create_comment( "Comment also created by PyGithub", path = "codegen/templates/GithubObject.MethodBody.UseResult.py", position = 3 )
self.assertEqual( comment.id, 1362001 )
self.assertEqual( comment.line, None )
self.assertEqual( comment.path, "codegen/templates/GithubObject.MethodBody.UseResult.py" )
self.assertEqual( comment.position, 3 )
def testEditCommitComment( self ):
comment = self.repo.get_comment( 1361949 )
comment.edit( "Comment edited by PyGithub" )
def testDeleteCommitComment( self ):
comment = self.repo.get_comment( 1361949 )
comment.delete()
def testCommitCommentsOnLine( self ):
commit = self.repo.get_commit( "6945921c529be14c3a8f566dd1e483674516d46d" )
comments = list( commit.get_comments() )
+1
View File
@@ -11,5 +11,6 @@ from NamedUser import *
from Hook import *
from Gist import *
from Authorization import *
from Download import *
Framework.main()
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
GET /repos/jacquev6/PyGithub/comments/1361949 {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4975'), ('content-length', '713'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"97ffd9ff8370f4f284873a6397d7cafd"'), ('date', 'Tue, 22 May 2012 18:44:06 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-22T18:43:17Z","position":null,"body":"Comment edited by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/comments/1361949","commit_id":"6945921c529be14c3a8f566dd1e483674516d46d","created_at":"2012-05-22T18:40:18Z","path":null,"line":null,"user":{"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-140.png","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146},"id":1361949,"html_url":"https://github.com/jacquev6/PyGithub/commit/6945921c529be14c3a8f566dd1e483674516d46d#commitcomment-1361949"}
DELETE /repos/jacquev6/PyGithub/comments/1361949 {} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4974'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Tue, 22 May 2012 18:44:06 GMT')]
@@ -0,0 +1,10 @@
GET /repos/jacquev6/PyGithub/comments/1361949 {} null
200
[('status', '200 OK'), ('content-length', '714'), ('x-ratelimit-remaining', '4979'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"eebb2ebe0274fc6672c9e7bad74e5f39"'), ('date', 'Tue, 22 May 2012 18:43:13 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"url":"https://api.github.com/repos/jacquev6/PyGithub/comments/1361949","path":null,"body":"Comment created by PyGithub","html_url":"https://github.com/jacquev6/PyGithub/commit/6945921c529be14c3a8f566dd1e483674516d46d#commitcomment-1361949","created_at":"2012-05-22T18:40:18Z","commit_id":"6945921c529be14c3a8f566dd1e483674516d46d","position":null,"updated_at":"2012-05-22T18:40:18Z","id":1361949,"line":null,"user":{"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-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146}}
PATCH /repos/jacquev6/PyGithub/comments/1361949 {} {"body": "Comment edited by PyGithub"}
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4978'), ('content-length', '713'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"97ffd9ff8370f4f284873a6397d7cafd"'), ('date', 'Tue, 22 May 2012 18:43:17 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-22T18:43:17Z","position":null,"body":"Comment edited by PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/comments/1361949","commit_id":"6945921c529be14c3a8f566dd1e483674516d46d","created_at":"2012-05-22T18:40:18Z","path":null,"line":null,"user":{"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-140.png","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146},"id":1361949,"html_url":"https://github.com/jacquev6/PyGithub/commit/6945921c529be14c3a8f566dd1e483674516d46d#commitcomment-1361949"}
+10
View File
@@ -0,0 +1,10 @@
GET /user {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4953'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"e1a1f6f825326642be4ed8e6f8427437"'), ('date', 'Tue, 22 May 2012 19:15:57 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"type":"User","disk_usage":16849,"bio":"","url":"https://api.github.com/users/jacquev6","total_private_repos":5,"plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"owned_private_repos":5,"public_repos":11,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","public_gists":1,"company":"Criteo","login":"jacquev6","email":"vincent@vincent-jacques.net","private_gists":5,"collaborators":0,"name":"Vincent Jacques","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","html_url":"https://github.com/jacquev6","created_at":"2010-07-09T06:10:06Z","blog":"http://vincent-jacques.net","location":"Paris, France","id":327146,"followers":13,"following":24,"hireable":false}
GET /repos/jacquev6/PyGithub {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4952'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c26fc3fce8f52d05f1adf2025bfe34ab"'), ('date', 'Tue, 22 May 2012 19:15:58 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"pushed_at":"2012-05-21T13:48:43Z","updated_at":"2012-05-22T19:15:29Z","homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","has_downloads":true,"watchers":13,"permissions":{"pull":true,"admin":true,"push":true},"fork":false,"svn_url":"https://github.com/jacquev6/PyGithub","has_wiki":false,"has_issues":true,"size":181,"private":false,"forks":2,"owner":{"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-140.png","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146},"name":"PyGithub","language":"Python","description":"Python library implementing the full Github API v3","clone_url":"https://github.com/jacquev6/PyGithub.git","ssh_url":"git@github.com:jacquev6/PyGithub.git","html_url":"https://github.com/jacquev6/PyGithub","created_at":"2012-02-25T12:53:47Z","id":3544490,"open_issues":17,"mirror_url":null,"git_url":"git://github.com/jacquev6/PyGithub.git"}
@@ -0,0 +1,5 @@
GET /repos/jacquev6/PyGithub/downloads/242550 {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4960'), ('content-length', '290'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"6d8a8b9509b1686543a96ec3c58b0293"'), ('date', 'Tue, 22 May 2012 19:03:36 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"content_type":"text/plain","download_count":0,"url":"https://api.github.com/repos/jacquev6/PyGithub/downloads/242550","size":1024,"name":"Foobar.txt","created_at":"2012-05-22T18:58:32Z","description":null,"html_url":"https://github.com/downloads/jacquev6/PyGithub/Foobar.txt","id":242550}
@@ -0,0 +1,5 @@
POST /repos/jacquev6/PyGithub/downloads {} {"description": "Download created by PyGithub", "name": "Foobar.txt", "content_type": "text/richtext", "size": 1024}
201
[('status', '201 Created'), ('x-ratelimit-remaining', '4957'), ('content-length', '1172'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"dec219bef9e193a28a08c8f5643c0ac3"'), ('date', 'Tue, 22 May 2012 19:11:49 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/downloads/242556')]
{"description":"Download created by PyGithub","acl":"public-read","accesskeyid":"1DWESVTPGHQVTX38V182","bucket":"github","content_type":"text/richtext","x-amz-meta-content-disposition":"attachment; filename=Foobar.txt","redirect":false,"expirationdate":"2112-05-22T19:11:49.000Z","policy":"ewogICAgJ2V4cGlyYXRpb24nOiAnMjExMi0wNS0yMlQxOToxMTo0OS4wMDBaJywKICAgICdjb25kaXRpb25zJzogWwogICAgICAgIHsnYnVja2V0JzogJ2dpdGh1Yid9LAogICAgICAgIHsna2V5JzogJ2Rvd25sb2Fkcy9qYWNxdWV2Ni9QeUdpdGh1Yi9Gb29iYXIudHh0J30sCiAgICAgICAgeydhY2wnOiAncHVibGljLXJlYWQnfSwKICAgICAgICB7J3N1Y2Nlc3NfYWN0aW9uX3N0YXR1cyc6ICcyMDEnfSwKICAgICAgICBbJ3N0YXJ0cy13aXRoJywgJyRGaWxlbmFtZScsICcnXSwKICAgICAgICBbJ3N0YXJ0cy13aXRoJywgJyRDb250ZW50LVR5cGUnLCAnJ10KICAgIF0KfQ==","s3_url":"https://github.s3.amazonaws.com/","html_url":"https://github.com/downloads/jacquev6/PyGithub/Foobar.txt","mime_type":"text/richtext","size":1024,"url":"https://api.github.com/repos/jacquev6/PyGithub/downloads/242556","download_count":0,"name":"Foobar.txt","prefix":"downloads/jacquev6/PyGithub","path":"downloads/jacquev6/PyGithub/Foobar.txt","id":242556,"signature":"8FCU/4rgT3ohXfE9N6HO7JgbuK4=","created_at":"2012-05-22T19:11:49Z"}
@@ -0,0 +1,5 @@
POST /repos/jacquev6/PyGithub/downloads {} {"name": "Foobar.txt", "size": 1024}
201
[('status', '201 Created'), ('x-ratelimit-remaining', '4954'), ('content-length', '1140'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"14a91323a46cfdfd53dfacffa96ab6a0"'), ('date', 'Tue, 22 May 2012 19:15:29 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/downloads/242562')]
{"accesskeyid":"1DWESVTPGHQVTX38V182","bucket":"github","content_type":"text/plain","download_count":0,"redirect":false,"mime_type":"text/plain","prefix":"downloads/jacquev6/PyGithub","expirationdate":"2112-05-22T19:15:29.000Z","url":"https://api.github.com/repos/jacquev6/PyGithub/downloads/242562","x-amz-meta-content-disposition":"attachment; filename=Foobar.txt","acl":"public-read","s3_url":"https://github.s3.amazonaws.com/","policy":"ewogICAgJ2V4cGlyYXRpb24nOiAnMjExMi0wNS0yMlQxOToxNToyOS4wMDBaJywKICAgICdjb25kaXRpb25zJzogWwogICAgICAgIHsnYnVja2V0JzogJ2dpdGh1Yid9LAogICAgICAgIHsna2V5JzogJ2Rvd25sb2Fkcy9qYWNxdWV2Ni9QeUdpdGh1Yi9Gb29iYXIudHh0J30sCiAgICAgICAgeydhY2wnOiAncHVibGljLXJlYWQnfSwKICAgICAgICB7J3N1Y2Nlc3NfYWN0aW9uX3N0YXR1cyc6ICcyMDEnfSwKICAgICAgICBbJ3N0YXJ0cy13aXRoJywgJyRGaWxlbmFtZScsICcnXSwKICAgICAgICBbJ3N0YXJ0cy13aXRoJywgJyRDb250ZW50LVR5cGUnLCAnJ10KICAgIF0KfQ==","size":1024,"signature":"Z2VR9HhhJdWkmhyoSZF+TT6hqIs=","name":"Foobar.txt","path":"downloads/jacquev6/PyGithub/Foobar.txt","created_at":"2012-05-22T19:15:29Z","description":null,"html_url":"https://github.com/downloads/jacquev6/PyGithub/Foobar.txt","id":242562}
+10
View File
@@ -0,0 +1,10 @@
GET /repos/jacquev6/PyGithub/downloads/242562 {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4951'), ('content-length', '290'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"dcabb0edb27a952d13d734c70e92c4f7"'), ('date', 'Tue, 22 May 2012 19:15:59 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"content_type":"text/plain","download_count":0,"url":"https://api.github.com/repos/jacquev6/PyGithub/downloads/242562","size":1024,"name":"Foobar.txt","created_at":"2012-05-22T19:15:29Z","description":null,"html_url":"https://github.com/downloads/jacquev6/PyGithub/Foobar.txt","id":242562}
DELETE /repos/jacquev6/PyGithub/downloads/242562 {} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4950'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Tue, 22 May 2012 19:16:03 GMT')]