From 7c4fc487c2a06f38ccabdaf60ae0f8d4c3442356 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 10 May 2012 20:18:03 +0100 Subject: [PATCH] Test AuthenticatedUser.create_repo (requires manual edition of generated code) --- src/github/AuthenticatedUser.py | 2 +- test/ReplayData/Repository.testCreate.txt | 5 +++++ test/Repository.py | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/ReplayData/Repository.testCreate.txt diff --git a/src/github/AuthenticatedUser.py b/src/github/AuthenticatedUser.py index c34ff171..218520c5 100644 --- a/src/github/AuthenticatedUser.py +++ b/src/github/AuthenticatedUser.py @@ -250,7 +250,7 @@ class AuthenticatedUser( object ): post_parameters[ "team_id" ] = team_id status, headers, data = self.__requester.request( "POST", - str( self.url ) + "/repos", + "https://api.github.com/user" + "/repos", None, post_parameters ) diff --git a/test/ReplayData/Repository.testCreate.txt b/test/ReplayData/Repository.testCreate.txt new file mode 100644 index 00000000..cd3fbfa9 --- /dev/null +++ b/test/ReplayData/Repository.testCreate.txt @@ -0,0 +1,5 @@ +POST /user/repos {} {"name": "TestPyGithub"} +201 +[('status', '201 Created'), ('x-ratelimit-remaining', '4996'), ('content-length', '1035'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"0dee1203022ede8b8374b387ba479ffd"'), ('date', 'Thu, 10 May 2012 19:17:12 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/TestPyGithub')] +{"mirror_url":null,"homepage":null,"clone_url":"https://github.com/jacquev6/TestPyGithub.git","html_url":"https://github.com/jacquev6/TestPyGithub","url":"https://api.github.com/repos/jacquev6/TestPyGithub","has_downloads":true,"watchers":1,"git_url":"git://github.com/jacquev6/TestPyGithub.git","permissions":{"admin":true,"pull":true,"push":true},"has_wiki":true,"has_issues":true,"fork":false,"forks":1,"language":null,"size":0,"description":null,"private":false,"created_at":"2012-05-10T19:17:12Z","open_issues":0,"svn_url":"https://github.com/jacquev6/TestPyGithub","owner":{"url":"https://api.github.com/users/jacquev6","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146},"name":"TestPyGithub","pushed_at":"2012-05-10T19:17:12Z","id":4288693,"ssh_url":"git@github.com:jacquev6/TestPyGithub.git","updated_at":"2012-05-10T19:17:12Z"} + diff --git a/test/Repository.py b/test/Repository.py index 1aa50fc0..999c3198 100644 --- a/test/Repository.py +++ b/test/Repository.py @@ -38,3 +38,7 @@ class Repository( Framework.TestCase ): self.assertEqual( repo.updated_at, "2012-05-08T19:27:43Z" ) self.assertEqual( repo.url, "https://api.github.com/repos/jacquev6/PyGithub" ) self.assertEqual( repo.watchers, 13 ) + + def testCreate( self ): + repo = self.user.create_repo( "TestPyGithub" ) + self.assertEqual( repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub" )