Skip to content

Commit

Permalink
Merge branch 'topic/RestoreTests' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquev6 committed Mar 19, 2012
2 parents a0cc821 + a655d04 commit 2469c6e
Show file tree
Hide file tree
Showing 34 changed files with 1,737 additions and 19 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ GithubCredentials.py
.coverage
/dist
/MANIFEST
ReplayDataForIntegrationTest*.txt
37 changes: 32 additions & 5 deletions IntegrationTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def __init__( self, file ):

def request( self, verb, url, input, headers ):
del headers[ "Authorization" ]
if( self.__file.readline().strip() != verb + " " + url + " " + str( headers ) + " " + input ):
expectation = self.__file.readline().strip()
if expectation != verb + " " + url + " " + str( headers ) + " " + input:
# print expectation, "!=", verb + " " + url + " " + str( headers ) + " " + input
raise RecordReplayException( "This test has been changed since last record. Please re-run this script with argument '--record'" )

def getresponse( self ):
Expand Down Expand Up @@ -126,7 +128,7 @@ def prepareReplay( self, test ):
raise RecordReplayException( "This test has never been recorded. Please re-run this script with argument '--record'" )

def __fileName( self, test ):
return "ReplayDataForIntegrationTest." + test + ".txt"
return "ReplayDataForIntegrationTest/" + test + ".txt"

def listTests( self ):
return [ f[ 4: ] for f in dir( self ) if f.startswith( "test" ) ]
Expand Down Expand Up @@ -185,12 +187,18 @@ def analyseCoverage( self ):
else:
uncoveredApis.add( verb + " " + currentApi )

print
if len( uncoveredMethods ) != 0:
print "Not covered (" + str( len( uncoveredMethods ) ) + "):"
print
header = "Not covered (" + str( len( uncoveredMethods ) ) + ")"
print header
print "=" * len( header )
print "\n".join( sorted( uncoveredMethods ) )

if len( uncoveredApis ) != 0:
print "Not implemented (" + str( len( uncoveredApis ) ) + "):"
print
header = "Not implemented (" + str( len( uncoveredApis ) ) + ")"
print header
print "=" * len( header )
print "\n".join( sorted( uncoveredApis ) )

def testAuthenticatedUserDetails( self ):
Expand Down Expand Up @@ -397,6 +405,17 @@ def testGitObjects( self ):
r.create_git_ref( "refs/tags/tagCreatedByPyGithub", tag.sha )
reTag = r.get_git_tag( tag.sha )

def testGitObjectsAlternative( self ):
o = self.g.get_organization( self.cobayeOrganization )
r = o.get_repo( "TestPyGithub" )

masterRef = r.get_git_ref( "refs/heads/master" )
masterCommit = r.get_git_commit( masterRef.object[ "sha" ] )
masterTree = r.get_git_tree( masterCommit.tree.sha, recursive = True )

blob = r.create_git_blob( "This blob was also created by PyGithub", encoding = "latin1" )
tree = r.create_git_tree( [ { "path": "new.bar", "mode": "100644", "type": "blob", "sha": blob.sha } ], base_tree = masterTree.sha )

def testHooks( self ):
u = self.g.get_user()
r = u.get_repo( "TestPyGithub" )
Expand Down Expand Up @@ -469,6 +488,9 @@ def testIssuesAndMilestones( self ):
m.delete()
self.printList( "Milestones", r.get_milestones(), lambda m: m.title )

def testIssuesForAuthenticatedUser( self ):
self.printList( "Issues", self.g.get_user().get_issues(), lambda i: i.title )

def testKeys( self ):
u = self.g.get_user()
self.printList( "Keys", u.get_keys(), lambda k: k.title )
Expand Down Expand Up @@ -523,6 +545,10 @@ def testPullRequest( self ):
p2.edit( state = "closed" )
self.printList( "Pull requests", r.get_pulls(), lambda p: p.title )

def testRepositoryCompare( self ):
r = self.g.get_user().get_repo( "PyGithub" )
print str( r.compare( "master", "develop" ) )[ :100 ]

def testRepositoryDetails( self ):
r1 = self.g.get_user().get_repo( "PyGithub" )
r2 = self.g.get_user().get_repo( "TestPyGithub" )
Expand Down Expand Up @@ -569,4 +595,5 @@ def testEmails( self ):
def printList( self, title, iterable, f = lambda x: x ):
print title + ":", ", ".join( str( f( x ) ) for x in iterable[ :10 ] ), "..." if len( iterable ) > 10 else ""

sys.setrecursionlimit( 50 )
IntegrationTest().main( sys.argv[ 1: ] )
5 changes: 5 additions & 0 deletions ReplayDataForIntegrationTest/AuthenticatedUserDetails.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GET /user/orgs {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4935'), ('content-length', '262'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"3454c1345755c67af87593d8c4c9f79d"'), ('date', 'Sun, 04 Mar 2012 09:31:50 GMT'), ('content-type', 'application/json; charset=utf-8')]
[{"login":"BeaverSoftware","url":"https://api.github.com/orgs/BeaverSoftware","id":1424031,"avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png"}]

50 changes: 50 additions & 0 deletions ReplayDataForIntegrationTest/Colaborators.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
GET /user {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4991'), ('content-length', '801'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"8516c4047fdb107d6a3ec08981b26671"'), ('date', 'Sun, 04 Mar 2012 08:21:36 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"disk_usage":17432,"type":"User","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","following":24,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jacquev6","public_gists":1,"public_repos":17,"hireable":false,"private_gists":2,"plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"blog":"http://vincent-jacques.net","location":"Paris, France","bio":"","collaborators":0,"company":"Criteo","total_private_repos":5,"url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","created_at":"2010-07-09T06:10:06Z","name":"Vincent Jacques","email":"vincent@vincent-jacques.net","owned_private_repos":5,"id":327146,"followers":12}

GET /repos/jacquev6/TestPyGithub {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4990'), ('content-length', '1067'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"14e49b73728e4b2ba7978b158e43208c"'), ('date', 'Sun, 04 Mar 2012 08:21:37 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"watchers":1,"pushed_at":"2012-03-03T07:43:16Z","homepage":"http://vincent-jacques.net/PyGithub","mirror_url":null,"has_downloads":true,"has_issues":true,"master_branch":null,"updated_at":"2012-03-03T07:53:19Z","forks":2,"fork":false,"svn_url":"https://github.com/jacquev6/TestPyGithub","language":null,"private":false,"size":84,"has_wiki":true,"url":"https://api.github.com/repos/jacquev6/TestPyGithub","html_url":"https://github.com/jacquev6/TestPyGithub","created_at":"2012-03-03T07:41:19Z","owner":{"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","url":"https://api.github.com/users/jacquev6","id":327146},"name":"TestPyGithub","git_url":"git://github.com/jacquev6/TestPyGithub.git","clone_url":"https://github.com/jacquev6/TestPyGithub.git","id":3609314,"ssh_url":"git@github.com:jacquev6/TestPyGithub.git","description":"Guinea-pig for PyGithub testing","open_issues":16}

GET /users/Lyloa {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('content-length', '554'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"f7d3e93a234c3e0d389940339ef8ac34"'), ('date', 'Sun, 04 Mar 2012 08:21:37 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"type":"User","gravatar_id":"1517ed584458ccf83e03f5d77d9699d7","following":0,"login":"Lyloa","blog":null,"public_gists":0,"location":"Paris","hireable":false,"company":null,"avatar_url":"https://secure.gravatar.com/avatar/1517ed584458ccf83e03f5d77d9699d7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","bio":null,"url":"https://api.github.com/users/Lyloa","html_url":"https://github.com/Lyloa","created_at":"2011-10-16T14:36:46Z","name":"Lyloa","email":"nyu@lyloa.net","id":1131432,"public_repos":0,"followers":1}

GET /repos/jacquev6/TestPyGithub/collaborators {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('content-length', '298'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"0f7fc68f68409b0b3c1fc6958ea0ad7b"'), ('date', 'Sun, 04 Mar 2012 08:21:38 GMT'), ('content-type', 'application/json; charset=utf-8')]
[{"gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","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","id":327146}]

PUT /repos/jacquev6/TestPyGithub/collaborators/Lyloa {} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4987'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sun, 04 Mar 2012 08:21:39 GMT')]


GET /repos/jacquev6/TestPyGithub/collaborators/Lyloa {} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4986'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sun, 04 Mar 2012 08:21:39 GMT')]


GET /repos/jacquev6/TestPyGithub/collaborators {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '590'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"04c1d43ae0dc4037aeb590f030dc5931"'), ('date', 'Sun, 04 Mar 2012 08:21:40 GMT'), ('content-type', 'application/json; charset=utf-8')]
[{"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","url":"https://api.github.com/users/jacquev6","id":327146},{"gravatar_id":"1517ed584458ccf83e03f5d77d9699d7","avatar_url":"https://secure.gravatar.com/avatar/1517ed584458ccf83e03f5d77d9699d7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"Lyloa","url":"https://api.github.com/users/Lyloa","id":1131432}]

DELETE /repos/jacquev6/TestPyGithub/collaborators/Lyloa {} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4984'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sun, 04 Mar 2012 08:21:40 GMT')]


GET /repos/jacquev6/TestPyGithub/collaborators/Lyloa {} null
404
[('status', '404 Not Found'), ('x-ratelimit-remaining', '4983'), ('content-length', '23'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"e66a7a6c91e2c26803f3f49feb7a883f"'), ('date', 'Sun, 04 Mar 2012 08:21:41 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"message":"Not Found"}

GET /repos/jacquev6/TestPyGithub/collaborators {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4982'), ('content-length', '298'), ('server', 'nginx/1.0.12'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"0f7fc68f68409b0b3c1fc6958ea0ad7b"'), ('date', 'Sun, 04 Mar 2012 08:21:42 GMT'), ('content-type', 'application/json; charset=utf-8')]
[{"gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","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","id":327146}]

Loading

0 comments on commit 2469c6e

Please sign in to comment.