Test Issue attributes

This commit is contained in:
Vincent Jacques
2012-05-18 20:40:24 +01:00
parent c75cb64d90
commit 030b23a3a9
9 changed files with 109 additions and 62 deletions
@@ -695,21 +695,21 @@
},
"attributes": [
{ "name": "assignee", "type": "NamedUser" },
{ "name": "body", "type": "@todo" },
{ "name": "closed_at", "type": "@todo" },
{ "name": "closed_by", "type": "@todo" },
{ "name": "comments", "type": "@todo" },
{ "name": "created_at", "type": "@todo" },
{ "name": "html_url", "type": "@todo" },
{ "name": "id", "type": "@todo" },
{ "name": "labels", "type": "@todo" },
{ "name": "body", "type": "string" },
{ "name": "closed_at", "type": "string" },
{ "name": "closed_by", "type": "NamedUser" },
{ "name": "comments", "type": "integer" },
{ "name": "created_at", "type": "string" },
{ "name": "html_url", "type": "string" },
{ "name": "id", "type": "integer" },
{ "name": "labels", "type": "list:Label" },
{ "name": "milestone", "type": "Milestone" },
{ "name": "number", "type": "@todo" },
{ "name": "number", "type": "integer" },
{ "name": "pull_request", "type": "@todo" },
{ "name": "state", "type": "@todo" },
{ "name": "title", "type": "@todo" },
{ "name": "updated_at", "type": "@todo" },
{ "name": "url", "type": "@todo" },
{ "name": "state", "type": "string" },
{ "name": "title", "type": "string" },
{ "name": "updated_at", "type": "string" },
{ "name": "url", "type": "string" },
{ "name": "user", "type": "NamedUser" }
],
"collections": [
@@ -3629,7 +3629,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "body"
},
@@ -3637,15 +3637,15 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "closed_at"
},
{
"type": {
"simple": true,
"simple": false,
"cardinality": "scalar",
"name": "@todo"
"name": "NamedUser"
},
"name": "closed_by"
},
@@ -3653,7 +3653,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "integer"
},
"name": "comments"
},
@@ -3661,7 +3661,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "created_at"
},
@@ -3669,7 +3669,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "html_url"
},
@@ -3677,15 +3677,15 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "integer"
},
"name": "id"
},
{
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"simple": false,
"cardinality": "list",
"name": "Label"
},
"name": "labels"
},
@@ -3701,7 +3701,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "integer"
},
"name": "number"
},
@@ -3717,7 +3717,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "state"
},
@@ -3725,7 +3725,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "title"
},
@@ -3733,7 +3733,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "updated_at"
},
@@ -3741,7 +3741,7 @@
"type": {
"simple": true,
"cardinality": "scalar",
"name": "@todo"
"name": "string"
},
"name": "url"
},
+13 -15
View File
@@ -506,21 +506,21 @@ Class `Issue`
Attributes
----------
* `assignee`: `NamedUser`
* `body`
* `closed_at`
* `closed_by`
* `comments`
* `created_at`
* `html_url`
* `id`
* `labels`
* `body`: string
* `closed_at`: string
* `closed_by`: `NamedUser`
* `comments`: integer
* `created_at`: string
* `html_url`: string
* `id`: integer
* `labels`: list of `Label`
* `milestone`: `Milestone`
* `number`
* `number`: integer
* `pull_request`
* `state`
* `title`
* `updated_at`
* `url`
* `state`: string
* `title`: string
* `updated_at`: string
* `url`: string
* `user`: `NamedUser`
Comments
@@ -856,7 +856,6 @@ Attributes
Comments
--------
* `create_comment( < body, commit_id, path, position > or < body, in_reply_to > )`: `PullRequestComment`
* `get_comment( id )`: `PullRequestComment`
* `id`
* `get_comments()`: list of `PullRequestComment`
@@ -1151,7 +1150,6 @@ Modification
Pulls
-----
* `create_pull( < title, body, base, head > or < issue, base, head > )`: `PullRequest`
* `get_pull( number )`: `PullRequest`
* `number`
* `get_pulls( [state] )`: list of `PullRequest`
+18 -2
View File
@@ -254,35 +254,51 @@ class Issue( object ):
assert isinstance( attributes[ "assignee" ], dict )
self.__assignee = NamedUser.NamedUser( self.__requester, attributes[ "assignee" ], completion = LazyCompletion )
if "body" in attributes and attributes[ "body" ] is not None:
assert isinstance( attributes[ "body" ], ( str, unicode ) )
self.__body = attributes[ "body" ]
if "closed_at" in attributes and attributes[ "closed_at" ] is not None:
assert isinstance( attributes[ "closed_at" ], ( str, unicode ) )
self.__closed_at = attributes[ "closed_at" ]
if "closed_by" in attributes and attributes[ "closed_by" ] is not None:
self.__closed_by = attributes[ "closed_by" ]
assert isinstance( attributes[ "closed_by" ], dict )
self.__closed_by = NamedUser.NamedUser( self.__requester, attributes[ "closed_by" ], completion = LazyCompletion )
if "comments" in attributes and attributes[ "comments" ] is not None:
assert isinstance( attributes[ "comments" ], int )
self.__comments = attributes[ "comments" ]
if "created_at" in attributes and attributes[ "created_at" ] is not None:
assert isinstance( attributes[ "created_at" ], ( str, unicode ) )
self.__created_at = attributes[ "created_at" ]
if "html_url" in attributes and attributes[ "html_url" ] is not None:
assert isinstance( attributes[ "html_url" ], ( str, unicode ) )
self.__html_url = attributes[ "html_url" ]
if "id" in attributes and attributes[ "id" ] is not None:
assert isinstance( attributes[ "id" ], int )
self.__id = attributes[ "id" ]
if "labels" in attributes and attributes[ "labels" ] is not None:
self.__labels = attributes[ "labels" ]
assert isinstance( attributes[ "labels" ], list ) and ( len( attributes[ "labels" ] ) == 0 or isinstance( attributes[ "labels" ][ 0 ], dict ) )
self.__labels = [
Label.Label( self.__requester, element, completion = LazyCompletion )
for element in attributes[ "labels" ]
]
if "milestone" in attributes and attributes[ "milestone" ] is not None:
assert isinstance( attributes[ "milestone" ], dict )
self.__milestone = Milestone.Milestone( self.__requester, attributes[ "milestone" ], completion = LazyCompletion )
if "number" in attributes and attributes[ "number" ] is not None:
assert isinstance( attributes[ "number" ], int )
self.__number = attributes[ "number" ]
if "pull_request" in attributes and attributes[ "pull_request" ] is not None:
self.__pull_request = attributes[ "pull_request" ]
if "state" in attributes and attributes[ "state" ] is not None:
assert isinstance( attributes[ "state" ], ( str, unicode ) )
self.__state = attributes[ "state" ]
if "title" in attributes and attributes[ "title" ] is not None:
assert isinstance( attributes[ "title" ], ( str, unicode ) )
self.__title = attributes[ "title" ]
if "updated_at" in attributes and attributes[ "updated_at" ] is not None:
assert isinstance( attributes[ "updated_at" ], ( str, unicode ) )
self.__updated_at = attributes[ "updated_at" ]
if "url" in attributes and attributes[ "url" ] is not None:
assert isinstance( attributes[ "url" ], ( str, unicode ) )
self.__url = attributes[ "url" ]
if "user" in attributes and attributes[ "user" ] is not None:
assert isinstance( attributes[ "user" ], dict )
+5
View File
@@ -105,6 +105,11 @@ class TestCase( unittest.TestCase ):
self.assertEqual( self.__file.readline(), "" )
self.__file.close()
class TestCaseWithRepo( TestCase ):
def setUp( self ):
TestCase.setUp( self )
self.repo = self.g.get_user().get_repo( "PyGithub" )
def main():
if "--record" in sys.argv:
TestCase.recordMode = True
+6 -11
View File
@@ -1,11 +1,6 @@
import Framework
class TestCaseWithRepo( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
self.repo = self.g.get_user().get_repo( "PyGithub" )
class Branch( TestCaseWithRepo ):
class Branch( Framework.TestCaseWithRepo ):
def testAttributes( self ):
branch = self.repo.get_branches()[ 0 ]
self.assertEqual( branch.name, "topic/RewriteWithGeneratedCode" )
@@ -30,7 +25,7 @@ class Branch( TestCaseWithRepo ):
self.assertEqual( branch.commit.stats.total, 20 )
self.assertEqual( branch.commit.url, "https://api.github.com/repos/jacquev6/PyGithub/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a" )
class GitBlob( TestCaseWithRepo ):
class GitBlob( Framework.TestCaseWithRepo ):
def testAttributes( self ):
blob = self.repo.get_git_blob( "53bce9fa919b4544e67275089b3ec5b44be20667" )
self.assertTrue( blob.content.startswith( "IyEvdXNyL2Jpbi9lbnYgcHl0aG9uCgpmcm9tIGRpc3R1dGlscy5jb3JlIGlt\ncG9ydCBzZXR1cAppbXBvcnQgdGV4dHdyYXAKCnNldHVwKAogICAgbmFtZSA9\n" ) )
@@ -45,7 +40,7 @@ class GitBlob( TestCaseWithRepo ):
blob = self.repo.create_git_blob( "Blob created by PyGithub", "latin1" )
self.assertEqual( blob.sha, "5dd930f591cd5188e9ea7200e308ad355182a1d8" )
class GitCommit( TestCaseWithRepo ):
class GitCommit( Framework.TestCaseWithRepo ):
def testAttributes( self ):
commit = self.repo.get_git_commit( "4303c5b90e2216d927155e9609436ccb8984c495" )
self.assertEqual( commit.author.name, "Vincent Jacques" )
@@ -62,7 +57,7 @@ class GitCommit( TestCaseWithRepo ):
self.assertEqual( commit.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad" )
self.assertEqual( commit.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495" )
class GitRef( TestCaseWithRepo ):
class GitRef( Framework.TestCaseWithRepo ):
def testAttributes( self ):
ref = self.repo.get_git_ref( "refs/heads/topic/RewriteWithGeneratedCode" )
self.assertEqual( ref.object.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a" )
@@ -77,7 +72,7 @@ class GitRef( TestCaseWithRepo ):
ref.edit( "4303c5b90e2216d927155e9609436ccb8984c495", force = True )
ref.delete()
class GitTag( TestCaseWithRepo ):
class GitTag( Framework.TestCaseWithRepo ):
def testAttributes( self ):
tag = self.repo.get_git_tag( "f5f37322407b02a80de4526ad88d5f188977bc3c" )
self.assertEqual( tag.message, "Version 0.6\n" )
@@ -91,7 +86,7 @@ class GitTag( TestCaseWithRepo ):
self.assertEqual( tag.tagger.name, "Vincent Jacques" )
self.assertEqual( tag.url, "https://api.github.com/repos/jacquev6/PyGithub/git/tags/f5f37322407b02a80de4526ad88d5f188977bc3c" )
class GitTree( TestCaseWithRepo ):
class GitTree( Framework.TestCaseWithRepo ):
def testAttributes( self ):
tree = self.repo.get_git_tree( "f492784d8ca837779650d1fb406a1a3587a764ad" )
self.assertEqual( tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad" )
+23 -5
View File
@@ -1,10 +1,6 @@
import Framework
class Milestones( Framework.TestCase ):
def setUp( self ):
Framework.TestCase.setUp( self )
self.repo = self.g.get_user().get_repo( "PyGithub" )
class Milestones( Framework.TestCaseWithRepo ):
def testAttributes( self ):
milestone = self.repo.get_milestone( 1 )
self.assertEqual( milestone.closed_issues, 2 )
@@ -18,3 +14,25 @@ class Milestones( Framework.TestCase ):
self.assertEqual( milestone.title, "Version 0.4" )
self.assertEqual( milestone.url, "https://api.github.com/repos/jacquev6/PyGithub/milestones/1" )
self.assertEqual( milestone.creator.login, "jacquev6" )
class Issues( Framework.TestCaseWithRepo ):
def testAttributes( self ):
issue = self.repo.get_issue( 1 )
self.assertEqual( issue.assignee.login, "jacquev6" )
self.assertEqual( issue.body, "" )
self.assertEqual( issue.closed_at, "2012-03-12T20:46:35Z" )
self.assertEqual( issue.closed_by.login, "jacquev6" )
self.assertEqual( issue.comments, 0 )
self.assertEqual( issue.created_at, "2012-02-27T09:11:14Z" )
self.assertEqual( issue.html_url, "https://github.com/jacquev6/PyGithub/issues/1" )
self.assertEqual( issue.id, 3397707 )
self.assertEqual( len( issue.labels ), 1 )
self.assertEqual( issue.labels[ 0 ].name, "Bug" )
self.assertEqual( issue.milestone.title, "Version 0.4" )
self.assertEqual( issue.number, 1 )
# self.assertEqual( issue.pull_request, "" )
self.assertEqual( issue.state, "closed" )
self.assertEqual( issue.title, "Gitub -> Github everywhere" )
self.assertEqual( issue.updated_at, "2012-03-12T20:46:35Z" )
self.assertEqual( issue.url, "https://api.github.com/repos/jacquev6/PyGithub/issues/1" )
self.assertEqual( issue.user.login, "jacquev6" )
+10
View File
@@ -0,0 +1,10 @@
GET /user {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4999'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"f76b5cd2cfc8c74f78bd97418b642046"'), ('date', 'Fri, 18 May 2012 19:30:30 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"collaborators":0,"type":"User","bio":"","public_gists":1,"company":"Criteo","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","total_private_repos":5,"public_repos":11,"private_gists":5,"plan":{"collaborators":1,"private_repos":5,"name":"micro","space":614400},"followers":13,"owned_private_repos":5,"login":"jacquev6","blog":"http://vincent-jacques.net","email":"vincent@vincent-jacques.net","disk_usage":16852,"html_url":"https://github.com/jacquev6","name":"Vincent Jacques","created_at":"2010-07-09T06:10:06Z","location":"Paris, France","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","id":327146,"following":24,"hireable":false}
GET /repos/jacquev6/PyGithub {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4998'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"7c62781b2ce6aff41b69c602184160ba"'), ('date', 'Fri, 18 May 2012 19:30:34 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"svn_url":"https://github.com/jacquev6/PyGithub","has_wiki":false,"has_issues":true,"updated_at":"2012-05-18T05:29:54Z","forks":2,"homepage":"http://vincent-jacques.net/PyGithub","git_url":"git://github.com/jacquev6/PyGithub.git","url":"https://api.github.com/repos/jacquev6/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","open_issues":17,"fork":false,"ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-18T05:18:16Z","mirror_url":null,"size":304,"private":false,"has_downloads":true,"watchers":13,"html_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","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","login":"jacquev6","id":327146},"name":"PyGithub","permissions":{"pull":true,"admin":true,"push":true},"language":"Python","description":"Python library implementing the full Github API v3","created_at":"2012-02-25T12:53:47Z","id":3544490}
@@ -0,0 +1,5 @@
GET /repos/jacquev6/PyGithub/issues/1 {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4997'), ('content-length', '1997'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"b7e46583baa189706dc79bb9ad16b23b"'), ('date', 'Fri, 18 May 2012 19:30:34 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"closed_by":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"state":"closed","user":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"title":"Gitub -> Github everywhere","comments":0,"updated_at":"2012-03-12T20:46:35Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"closed_at":"2012-03-12T20:46:35Z","body":"","number":1,"milestone":{"due_on":"2012-03-13T07:00:00Z","state":"closed","creator":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"description":"","title":"Version 0.4","open_issues":0,"closed_issues":2,"number":1,"url":"https://api.github.com/repos/jacquev6/PyGithub/milestones/1","id":93546,"created_at":"2012-03-08T12:22:10Z"},"url":"https://api.github.com/repos/jacquev6/PyGithub/issues/1","assignee":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"labels":[{"color":"e10c02","url":"https://api.github.com/repos/jacquev6/PyGithub/labels/Bug","name":"Bug"}],"id":3397707,"html_url":"https://github.com/jacquev6/PyGithub/issues/1","created_at":"2012-02-27T09:11:14Z"}