Test Hooks

This commit is contained in:
Vincent Jacques
2012-05-19 07:04:24 +01:00
parent da3bea6922
commit 667937b437
10 changed files with 129 additions and 1 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ class TestCase( unittest.TestCase ):
def __openFile( self, mode ):
for ( _, _, functionName, _ ) in traceback.extract_stack():
if functionName.startswith( "test" ) or functionName == "setUp" or functionName == "tearDown":
if functionName.startswith( "test" ) and functionName != "test" or functionName == "setUp" or functionName == "tearDown":
fileName = os.path.join( os.path.dirname( __file__ ), "ReplayData", self.__class__.__name__ + "." + functionName + ".txt" )
if fileName != self.__fileName:
self.__closeReplayFileIfNeeded()
+52
View File
@@ -0,0 +1,52 @@
import Framework
class Hook( Framework.TestCaseWithRepo ):
def testCreateWithMinimalParameters( self ):
### @todo Implement https://api.github.com/hooks, which is not described, but refered by http://developer.github.com/v3/repos/hooks/#create-a-hook
hook = self.repo.create_hook( "web", { "url": "http://foobar.com" } )
self.assertEqual( hook.active, True )
self.assertEqual( hook.config, { "url": "http://foobar.com" } )
self.assertEqual( hook.created_at, "2012-05-19T05:03:14Z" )
self.assertEqual( hook.events, [ "push" ] )
self.assertEqual( hook.id, 257967 )
self.assertEqual( hook.last_response, { "status": "unused", "message": None, "code": None } )
self.assertEqual( hook.name, "web" )
self.assertEqual( hook.updated_at, "2012-05-19T05:03:14Z" )
self.assertEqual( hook.url, "https://api.github.com/repos/jacquev6/PyGithub/hooks/257967" )
def testEditWithMinimalParameters( self ):
hook = self.repo.get_hook( 257967 )
hook.edit( "web", { "url": "http://foobar.com/hook" } )
self.assertEqual( hook.config, { "url": "http://foobar.com/hook" } )
self.assertEqual( hook.updated_at, "2012-05-19T05:08:16Z" )
def testDelete( self ):
hook = self.repo.get_hook( 257967 )
hook.delete()
def testCreateWithAllParameters( self ):
hook = self.repo.create_hook( "web", { "url": "http://foobar.com" }, [ "fork" ], False )
self.assertEqual( hook.active, True ) # WTF
self.assertEqual( hook.config, { "url": "http://foobar.com" } )
self.assertEqual( hook.created_at, "2012-05-19T06:01:45Z" )
self.assertEqual( hook.events, [ "fork" ] )
self.assertEqual( hook.id, 257993 )
self.assertEqual( hook.last_response, { "status": "unused", "message": None, "code": None } )
self.assertEqual( hook.name, "web" )
self.assertEqual( hook.updated_at, "2012-05-19T06:01:45Z" )
self.assertEqual( hook.url, "https://api.github.com/repos/jacquev6/PyGithub/hooks/257993" )
def testTest( self ):
hook = self.repo.get_hook( 257993 )
hook.test() # This does not update attributes of hook
def testEditWithAllParameters( self ):
hook = self.repo.get_hook( 257993 )
hook.edit( "web", { "url": "http://foobar.com" }, events = [ "fork", "push" ] )
self.assertEqual( hook.events, [ "fork", "push" ] )
hook.edit( "web", { "url": "http://foobar.com" }, add_events = [ "push" ] )
self.assertEqual( hook.events, [ "fork", "push" ] )
hook.edit( "web", { "url": "http://foobar.com" }, remove_events = [ "fork" ] )
self.assertEqual( hook.events, [ "push" ] )
hook.edit( "web", { "url": "http://foobar.com" }, active = True )
self.assertEqual( hook.active, True )
+1
View File
@@ -8,5 +8,6 @@ from Repository import *
from Organization import *
from MilestonesAndIssues import *
from NamedUser import *
from Hook import *
Framework.main()
+10
View File
@@ -0,0 +1,10 @@
GET /user {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1e23ec567c20df43998d10ca594a6751"'), ('date', 'Sat, 19 May 2012 05:08:59 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"type":"User","owned_private_repos":5,"blog":"http://vincent-jacques.net","company":"Criteo","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","plan":{"private_repos":5,"collaborators":1,"name":"micro","space":614400},"followers":13,"public_repos":11,"hireable":false,"login":"jacquev6","collaborators":0,"public_gists":1,"email":"vincent@vincent-jacques.net","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","disk_usage":16768,"html_url":"https://github.com/jacquev6","name":"Vincent Jacques","bio":"","private_gists":5,"created_at":"2010-07-09T06:10:06Z","location":"Paris, France","id":327146,"total_private_repos":5,"following":24}
GET /repos/jacquev6/PyGithub {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"9980e3e204ce293ebdb8dc90ff290268"'), ('date', 'Sat, 19 May 2012 05:09:00 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-18T20:30:15Z","forks":2,"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","mirror_url":null,"clone_url":"https://github.com/jacquev6/PyGithub.git","git_url":"git://github.com/jacquev6/PyGithub.git","open_issues":17,"fork":false,"ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-18T20:30:14Z","size":220,"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","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","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 @@
POST /repos/jacquev6/PyGithub/hooks {} {"active": false, "config": {"url": "http://foobar.com"}, "name": "web", "events": ["fork"]}
201
[('status', '201 Created'), ('x-ratelimit-remaining', '4997'), ('content-length', '298'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c3b371e4de1a0ec350b3fcc0c458e0f9"'), ('date', 'Sat, 19 May 2012 06:01:45 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/hooks/257993')]
{"updated_at":"2012-05-19T06:01:45Z","last_response":{"status":"unused","message":null,"code":null},"events":["fork"],"url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257993","active":true,"name":"web","config":{"url":"http://foobar.com"},"id":257993,"created_at":"2012-05-19T06:01:45Z"}
@@ -0,0 +1,5 @@
POST /repos/jacquev6/PyGithub/hooks {} {"config": {"url": "http://foobar.com"}, "name": "web"}
201
[('status', '201 Created'), ('x-ratelimit-remaining', '4994'), ('content-length', '298'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"276d18854081948260c44cf645c54bd0"'), ('date', 'Sat, 19 May 2012 05:03:14 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/hooks/257967')]
{"updated_at":"2012-05-19T05:03:14Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257967","config":{"url":"http://foobar.com"},"last_response":{"status":"unused","message":null,"code":null},"active":true,"events":["push"],"name":"web","created_at":"2012-05-19T05:03:14Z","id":257967}
+10
View File
@@ -0,0 +1,10 @@
GET /repos/jacquev6/PyGithub/hooks/257967 {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '303'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"a686c4d4f706840e166ebafdfd05f41f"'), ('date', 'Sat, 19 May 2012 05:09:01 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-19T05:08:16Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257967","config":{"url":"http://foobar.com/hook"},"last_response":{"status":"unused","message":null,"code":null},"active":true,"events":["push"],"name":"web","created_at":"2012-05-19T05:03:14Z","id":257967}
DELETE /repos/jacquev6/PyGithub/hooks/257967 {} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4986'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sat, 19 May 2012 05:09:01 GMT')]
@@ -0,0 +1,25 @@
GET /repos/jacquev6/PyGithub/hooks/257993 {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('content-length', '298'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"73e795da2a2d325298007f3b78822b98"'), ('date', 'Sat, 19 May 2012 06:03:18 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-19T06:02:36Z","last_response":{"status":"unused","message":null,"code":null},"events":["push"],"url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257993","active":true,"name":"web","config":{"url":"http://foobar.com"},"id":257993,"created_at":"2012-05-19T06:01:45Z"}
PATCH /repos/jacquev6/PyGithub/hooks/257993 {} {"config": {"url": "http://foobar.com"}, "name": "web", "events": ["fork", "push"]}
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '305'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"43f8b86dbc2f5bbfde20abb9d9142206"'), ('date', 'Sat, 19 May 2012 06:03:18 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-19T06:03:18Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257993","last_response":{"status":"unused","message":null,"code":null},"config":{"url":"http://foobar.com"},"active":true,"events":["fork","push"],"name":"web","created_at":"2012-05-19T06:01:45Z","id":257993}
PATCH /repos/jacquev6/PyGithub/hooks/257993 {} {"config": {"url": "http://foobar.com"}, "name": "web", "add_events": ["push"]}
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('content-length', '305'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"f372cc9359ed1d3b3fb8d484a09b36d7"'), ('date', 'Sat, 19 May 2012 06:03:19 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-19T06:03:19Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257993","last_response":{"status":"unused","message":null,"code":null},"config":{"url":"http://foobar.com"},"active":true,"events":["fork","push"],"name":"web","created_at":"2012-05-19T06:01:45Z","id":257993}
PATCH /repos/jacquev6/PyGithub/hooks/257993 {} {"remove_events": ["fork"], "config": {"url": "http://foobar.com"}, "name": "web"}
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '298'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"223ecc83a014738547fd99c826e3f125"'), ('date', 'Sat, 19 May 2012 06:03:19 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-19T06:03:19Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257993","config":{"url":"http://foobar.com"},"active":true,"last_response":{"status":"unused","message":null,"code":null},"events":["push"],"name":"web","created_at":"2012-05-19T06:01:45Z","id":257993}
PATCH /repos/jacquev6/PyGithub/hooks/257993 {} {"active": true, "config": {"url": "http://foobar.com"}, "name": "web"}
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4984'), ('content-length', '298'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"711cf06c29a923c290e1af74dc3e019d"'), ('date', 'Sat, 19 May 2012 06:03:20 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-19T06:03:20Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257993","last_response":{"status":"unused","message":null,"code":null},"config":{"url":"http://foobar.com"},"active":true,"events":["push"],"name":"web","created_at":"2012-05-19T06:01:45Z","id":257993}
@@ -0,0 +1,10 @@
GET /repos/jacquev6/PyGithub/hooks/257967 {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4991'), ('content-length', '298'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"7be10de17b101889781f9b1fde89d38f"'), ('date', 'Sat, 19 May 2012 05:08:16 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"last_response":{"status":"unused","message":null,"code":null},"updated_at":"2012-05-19T05:03:14Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257967","config":{"url":"http://foobar.com"},"active":true,"events":["push"],"name":"web","created_at":"2012-05-19T05:03:14Z","id":257967}
PATCH /repos/jacquev6/PyGithub/hooks/257967 {} {"config": {"url": "http://foobar.com/hook"}, "name": "web"}
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4990'), ('content-length', '303'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"8628a600a78bd5171c9e8d23b1ec22de"'), ('date', 'Sat, 19 May 2012 05:08:16 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"last_response":{"status":"unused","message":null,"code":null},"updated_at":"2012-05-19T05:08:16Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257967","config":{"url":"http://foobar.com/hook"},"active":true,"events":["push"],"name":"web","created_at":"2012-05-19T05:03:14Z","id":257967}
+10
View File
@@ -0,0 +1,10 @@
GET /repos/jacquev6/PyGithub/hooks/257993 {} null
200
[('status', '200 OK'), ('x-ratelimit-remaining', '4981'), ('content-length', '298'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"f4a973ea4a9c930d4a89ea010190c734"'), ('date', 'Sat, 19 May 2012 06:04:06 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"updated_at":"2012-05-19T06:03:20Z","url":"https://api.github.com/repos/jacquev6/PyGithub/hooks/257993","config":{"url":"http://foobar.com"},"active":true,"last_response":{"status":"unused","message":null,"code":null},"events":["push"],"name":"web","created_at":"2012-05-19T06:01:45Z","id":257993}
POST /repos/jacquev6/PyGithub/hooks/257993/test {} null
204
[('status', '204 No Content'), ('x-ratelimit-remaining', '4980'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Sat, 19 May 2012 06:04:06 GMT')]