From 5093cc255a9bf8cf3589a6408331a75de7ceb7a9 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sun, 20 Oct 2013 19:03:35 -0700 Subject: [PATCH] Fix public/private in Repository.edit (#199) --- README.rst | 1 + github/Repository.py | 10 +++++----- .../ReplayData/Repository.testEditWithAllArguments.txt | 2 +- github/tests/Repository.py | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 619447cc..8f82f590 100644 --- a/README.rst +++ b/README.rst @@ -21,6 +21,7 @@ Starting today (September 5th, 2013), we now need more than 8 bits to store the * `Implement `_ ``Github.get_hook(name)``. Thank you `klmitch `_ for asking * In case bad data is returned by Github API v3, `raise `_ an exception only when the user accesses the faulty attribute, not when constructing the object containing this attribute. Thank you `klmitch `_ for asking +* `Fix `_ parameter public/private of ``Repository.edit``. Thank you `daireobroin449 `_ for reporting the issue What's missing? =============== diff --git a/github/Repository.py b/github/Repository.py index 8abf7886..8e27710f 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -982,13 +982,13 @@ class Repository(github.GithubObject.CompletableGithubObject): self.url ) - def edit(self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, public=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, default_branch=github.GithubObject.NotSet): + def edit(self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, default_branch=github.GithubObject.NotSet): """ :calls: `PATCH /repos/:owner/:repo `_ :param name: string :param description: string :param homepage: string - :param public: bool + :param private: bool :param has_issues: bool :param has_wiki: bool :param has_downloads: bool @@ -998,7 +998,7 @@ class Repository(github.GithubObject.CompletableGithubObject): assert isinstance(name, (str, unicode)), name assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage - assert public is github.GithubObject.NotSet or isinstance(public, bool), public + assert private is github.GithubObject.NotSet or isinstance(private, bool), private assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads @@ -1010,8 +1010,8 @@ class Repository(github.GithubObject.CompletableGithubObject): post_parameters["description"] = description if homepage is not github.GithubObject.NotSet: post_parameters["homepage"] = homepage - if public is not github.GithubObject.NotSet: - post_parameters["public"] = public + if private is not github.GithubObject.NotSet: + post_parameters["private"] = private if has_issues is not github.GithubObject.NotSet: post_parameters["has_issues"] = has_issues if has_wiki is not github.GithubObject.NotSet: diff --git a/github/tests/ReplayData/Repository.testEditWithAllArguments.txt b/github/tests/ReplayData/Repository.testEditWithAllArguments.txt index 2af01eac..c98b91b1 100644 --- a/github/tests/ReplayData/Repository.testEditWithAllArguments.txt +++ b/github/tests/ReplayData/Repository.testEditWithAllArguments.txt @@ -4,7 +4,7 @@ api.github.com None /repos/jacquev6/PyGithub {'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} -{"has_wiki": false, "name": "PyGithub", "has_downloads": true, "has_issues": true, "homepage": "http://vincent-jacques.net/PyGithub", "public": true, "description": "Description edited by PyGithub"} +{"has_wiki": false, "name": "PyGithub", "has_downloads": true, "has_issues": true, "homepage": "http://vincent-jacques.net/PyGithub", "private": true, "description": "Description edited by PyGithub"} 200 [('status', '200 OK'), ('x-ratelimit-remaining', '4953'), ('content-length', '1109'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"749313ec2d171323deb61f9f4c85e84f"'), ('date', 'Sat, 26 May 2012 11:22:13 GMT'), ('content-type', 'application/json; charset=utf-8')] {"clone_url":"https://github.com/jacquev6/PyGithub.git","has_downloads":true,"watchers":13,"updated_at":"2012-05-26T11:22:13Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"http://vincent-jacques.net/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","has_wiki":false,"has_issues":true,"fork":false,"forks":2,"size":412,"git_url":"git://github.com/jacquev6/PyGithub.git","private":false,"open_issues":16,"mirror_url":null,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/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","login":"jacquev6","id":327146},"name":"PyGithub","language":"Python","description":"Description edited by PyGithub","ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-26T10:01:38Z","created_at":"2012-02-25T12:53:47Z","id":3544490,"html_url":"https://github.com/jacquev6/PyGithub","full_name":"jacquev6/PyGithub"} diff --git a/github/tests/Repository.py b/github/tests/Repository.py index c1f968ce..ff696f62 100644 --- a/github/tests/Repository.py +++ b/github/tests/Repository.py @@ -72,7 +72,7 @@ class Repository(Framework.TestCase): self.repo.edit("PyGithub") def testEditWithAllArguments(self): - self.repo.edit("PyGithub", "Description edited by PyGithub", "http://vincent-jacques.net/PyGithub", public=True, has_issues=True, has_wiki=False, has_downloads=True) + self.repo.edit("PyGithub", "Description edited by PyGithub", "http://vincent-jacques.net/PyGithub", private=True, has_issues=True, has_wiki=False, has_downloads=True) self.assertEqual(self.repo.description, "Description edited by PyGithub") self.repo.edit("PyGithub", "Python library implementing the full Github API v3") self.assertEqual(self.repo.description, "Python library implementing the full Github API v3")