Test GitTag attributes

This commit is contained in:
Vincent Jacques
2012-05-10 19:22:33 +01:00
parent 5c18c20ec4
commit 2e76c9b7c5
6 changed files with 62 additions and 22 deletions
@@ -581,12 +581,12 @@
{
"name": "GitTag",
"attributes": [
{ "name": "message", "type": "@todo" },
{ "name": "object", "type": "@todo" },
{ "name": "sha", "type": "@todo" },
{ "name": "tag", "type": "@todo" },
{ "name": "tagger", "type": "@todo" },
{ "name": "url", "type": "@todo" }
{ "name": "message", "type": "string" },
{ "name": "object", "type": "GitObject" },
{ "name": "sha", "type": "string" },
{ "name": "tag", "type": "string" },
{ "name": "tagger", "type": "GitAuthor" },
{ "name": "url", "type": "string" }
],
"collections": [
]
@@ -3287,15 +3287,15 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "message"
},
{
"type": {
"simple": true,
"simple": false,
"cardinality": "scalar",
"name": "@todo"
"name": "GitObject"
},
"name": "object"
},
@@ -3303,7 +3303,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "sha"
},
@@ -3311,15 +3311,15 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "tag"
},
{
"type": {
"simple": true,
"simple": false,
"cardinality": "scalar",
"name": "@todo"
"name": "GitAuthor"
},
"name": "tagger"
},
@@ -3327,7 +3327,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "url"
}
+6 -6
View File
@@ -439,12 +439,12 @@ Class `GitTag`
Attributes
----------
* `message`
* `object`
* `sha`
* `tag`
* `tagger`
* `url`
* `message`: string
* `object`: `GitObject`
* `sha`: string
* `tag`: string
* `tagger`: `GitAuthor`
* `url`: string
Class `GitTree`
===============
+10 -2
View File
@@ -2,6 +2,8 @@
# Do not modify it manually, your work would be lost.
import PaginatedList
import GitAuthor
import GitObject
# This allows None as a valid value for an optional parameter
class DefaultValueForOptionalParametersType:
@@ -72,14 +74,20 @@ class GitTag( object ):
def __useAttributes( self, attributes ):
#@todo No need to check if attribute is in attributes when attribute is mandatory
if "message" in attributes and attributes[ "message" ] is not None:
assert isinstance( attributes[ "message" ], ( str, unicode ) )
self.__message = attributes[ "message" ]
if "object" in attributes and attributes[ "object" ] is not None:
self.__object = attributes[ "object" ]
assert isinstance( attributes[ "object" ], dict )
self.__object = GitObject.GitObject( self.__requester, attributes[ "object" ], lazy = True )
if "sha" in attributes and attributes[ "sha" ] is not None:
assert isinstance( attributes[ "sha" ], ( str, unicode ) )
self.__sha = attributes[ "sha" ]
if "tag" in attributes and attributes[ "tag" ] is not None:
assert isinstance( attributes[ "tag" ], ( str, unicode ) )
self.__tag = attributes[ "tag" ]
if "tagger" in attributes and attributes[ "tagger" ] is not None:
self.__tagger = attributes[ "tagger" ]
assert isinstance( attributes[ "tagger" ], dict )
self.__tagger = GitAuthor.GitAuthor( self.__requester, attributes[ "tagger" ], lazy = True )
if "url" in attributes and attributes[ "url" ] is not None:
assert isinstance( attributes[ "url" ], ( str, unicode ) )
self.__url = attributes[ "url" ]
+17
View File
@@ -34,6 +34,23 @@ class GitCommit( Framework.TestCase ):
self.assertEqual( self.c.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad" )
self.assertEqual( self.c.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495" )
class GitTag( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
self.t = self.g.get_user().get_repo( "PyGithub" ).get_git_tag( "f5f37322407b02a80de4526ad88d5f188977bc3c" )
def testAttributes( self ):
self.assertEqual( self.t.message, "Version 0.6\n" )
self.assertEqual( self.t.object.sha, "4303c5b90e2216d927155e9609436ccb8984c495" )
self.assertEqual( self.t.object.type, "commit" )
self.assertEqual( self.t.object.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495" )
self.assertEqual( self.t.sha, "f5f37322407b02a80de4526ad88d5f188977bc3c" )
self.assertEqual( self.t.tag, "v0.6" )
self.assertEqual( self.t.tagger.date, "2012-05-10T11:14:15-07:00" )
self.assertEqual( self.t.tagger.email, "vincent@vincent-jacques.net" )
self.assertEqual( self.t.tagger.name, "Vincent Jacques" )
self.assertEqual( self.t.url, "https://api.github.com/repos/jacquev6/PyGithub/git/tags/f5f37322407b02a80de4526ad88d5f188977bc3c" )
class GitTree( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
+15
View File
@@ -0,0 +1,15 @@
GET /user {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"395009f2efb6155eaa75de8a8bdb0aa5"'), ('date', 'Thu, 10 May 2012 18:17:26 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"type":"User","bio":"","public_repos":10,"public_gists":1,"total_private_repos":5,"company":"Criteo","private_gists":5,"followers":13,"following":24,"html_url":"https://github.com/jacquev6","created_at":"2010-07-09T06:10:06Z","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","owned_private_repos":5,"login":"jacquev6","disk_usage":16676,"name":"Vincent Jacques","location":"Paris, France","email":"vincent@vincent-jacques.net","collaborators":0,"blog":"http://vincent-jacques.net","hireable":false,"url":"https://api.github.com/users/jacquev6","id":327146,"plan":{"private_repos":5,"space":614400,"name":"micro","collaborators":1}}
GET /repos/jacquev6/PyGithub {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4995'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"dcb9725cc9016e7c13454c8958619b0d"'), ('date', 'Thu, 10 May 2012 18:17:27 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"homepage":"http://vincent-jacques.net/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","url":"https://api.github.com/repos/jacquev6/PyGithub","has_downloads":true,"watchers":13,"permissions":{"admin":true,"pull":true,"push":true},"mirror_url":null,"has_wiki":false,"has_issues":true,"fork":false,"forks":2,"language":"Python","size":196,"description":"Python library implementing the full Github API v3","html_url":"https://github.com/jacquev6/PyGithub","private":false,"created_at":"2012-02-25T12:53:47Z","open_issues":15,"svn_url":"https://github.com/jacquev6/PyGithub","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","pushed_at":"2012-05-10T18:14:23Z","id":3544490,"ssh_url":"git@github.com:jacquev6/PyGithub.git","git_url":"git://github.com/jacquev6/PyGithub.git","updated_at":"2012-05-10T18:14:23Z"}
GET /repos/jacquev6/PyGithub/git/tags/f5f37322407b02a80de4526ad88d5f188977bc3c {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4994'), ('content-length', '487'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1dd282b50e691f8f162ef9355dad8771"'), ('date', 'Thu, 10 May 2012 18:17:28 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/tags/f5f37322407b02a80de4526ad88d5f188977bc3c","tag":"v0.6","message":"Version 0.6\n","object":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495","type":"commit","sha":"4303c5b90e2216d927155e9609436ccb8984c495"},"tagger":{"email":"vincent@vincent-jacques.net","date":"2012-05-10T11:14:15-07:00","name":"Vincent Jacques"},"sha":"f5f37322407b02a80de4526ad88d5f188977bc3c"}