diff --git a/IntegrationTest.py b/IntegrationTest.py index 690031a9..04896d0f 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -371,6 +371,24 @@ class IntegrationTest: r.create_git_ref( "refs/tags/tagCreatedByPyGithub", tag.sha ) reTag = r.get_git_tag( tag.sha ) + def testHooks( self ): + u = self.g.get_user() + r = u.get_repo( "TestPyGithub" ) + + self.printList( "Hooks", r.get_hooks(), lambda h: h.name + str( h.config ) ) + h = r.create_hook( "web", { "url": "http://www.invalid.org" } ) + self.printList( "Hooks", r.get_hooks(), lambda h: h.name + str( h.config ) ) + h.edit( "web", { "url": "http://www.postbin.org/w5cgjr" } ) + self.printList( "Hooks", r.get_hooks(), lambda h: h.name + str( h.config ) ) + + sameHook = r.get_hook( h.id ) + + ### @todo Uncomment when API `/repos/:user/:repo/hooks/:id/test` is implemented + # h.test() + + h.delete() + self.printList( "Hooks", r.get_hooks(), lambda h: h.name + str( h.config ) ) + def testIssuesAndMilestones( self ): u = self.g.get_user() r = u.get_repo( "TestPyGithub" ) diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 3ff85f2c..f14e4158 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -5,12 +5,13 @@ from GithubObject import * Hook = GithubObject( "Hook", - BaseUrl( lambda obj: obj._repo._baseUrl + "/hooks/" + obj.id ), + BaseUrl( lambda obj: obj._repo._baseUrl + "/hooks/" + str( obj.id ) ), InternalSimpleAttributes( - ### @todo + "url", "updated_at", "created_at", "name", "events", "active", "config", + "id", "last_response", "_repo", ### Ugly hack ), - Editable( [], [] ), #### @todo + Editable( [ "name", "config" ], [ "events", "add_events", "remove_events", "active" ] ), Deletable(), ) @@ -422,7 +423,7 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ExternalListOfObjects( "hooks", "hook", Hook, ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), ### @todo + ElementCreatable( [ "name", "config" ], [ "events", "active" ], __modifyAttributesForObjectsReferingRepo ), ), ExternalListOfObjects( "keys", "key", RepositoryKey, ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),