diff --git a/github/Organization.py b/github/Organization.py index 66346af3ab..2283ce497b 100644 --- a/github/Organization.py +++ b/github/Organization.py @@ -14,9 +14,10 @@ # Copyright 2016 Matthew Neal # # Copyright 2016 Michael Pereira # # Copyright 2016 Peter Buckley # -# Copyright 2017 Balázs Rostás # +# Copyright 2017 Balázs Rostás # # Copyright 2018 Anton Nguyen # # Copyright 2018 sfdye # +# Copyright 2018 Jacopo Notarstefano # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # @@ -105,6 +106,14 @@ def created_at(self): self._completeIfNotSet(self._created_at) return self._created_at.value + @property + def description(self): + """ + :type: string + """ + self._completeIfNotSet(self._description) + return self._description.value + @property def disk_usage(self): """ @@ -483,12 +492,13 @@ def delete_hook(self, id): self.url + "/hooks/" + str(id) ) - def edit(self, billing_email=github.GithubObject.NotSet, blog=github.GithubObject.NotSet, company=github.GithubObject.NotSet, email=github.GithubObject.NotSet, location=github.GithubObject.NotSet, name=github.GithubObject.NotSet): + def edit(self, billing_email=github.GithubObject.NotSet, blog=github.GithubObject.NotSet, company=github.GithubObject.NotSet, description=github.GithubObject.NotSet, email=github.GithubObject.NotSet, location=github.GithubObject.NotSet, name=github.GithubObject.NotSet): """ :calls: `PATCH /orgs/:org `_ :param billing_email: string :param blog: string :param company: string + :param description: string :param email: string :param location: string :param name: string @@ -497,6 +507,7 @@ def edit(self, billing_email=github.GithubObject.NotSet, blog=github.GithubObjec assert billing_email is github.GithubObject.NotSet or isinstance(billing_email, (str, unicode)), billing_email assert blog is github.GithubObject.NotSet or isinstance(blog, (str, unicode)), blog assert company is github.GithubObject.NotSet or isinstance(company, (str, unicode)), company + assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email assert location is github.GithubObject.NotSet or isinstance(location, (str, unicode)), location assert name is github.GithubObject.NotSet or isinstance(name, (str, unicode)), name @@ -507,6 +518,8 @@ def edit(self, billing_email=github.GithubObject.NotSet, blog=github.GithubObjec post_parameters["blog"] = blog if company is not github.GithubObject.NotSet: post_parameters["company"] = company + if description is not github.GithubObject.NotSet: + post_parameters["description"] = description if email is not github.GithubObject.NotSet: post_parameters["email"] = email if location is not github.GithubObject.NotSet: @@ -834,6 +847,7 @@ def _initAttributes(self): self._collaborators = github.GithubObject.NotSet self._company = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet + self._description = github.GithubObject.NotSet self._disk_usage = github.GithubObject.NotSet self._email = github.GithubObject.NotSet self._events_url = github.GithubObject.NotSet @@ -871,6 +885,8 @@ def _useAttributes(self, attributes): self._company = self._makeStringAttribute(attributes["company"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "description" in attributes: # pragma no branch + self._description = self._makeStringAttribute(attributes["description"]) if "disk_usage" in attributes: # pragma no branch self._disk_usage = self._makeIntAttribute(attributes["disk_usage"]) if "email" in attributes: # pragma no branch diff --git a/github/tests/Organization.py b/github/tests/Organization.py index 82f92fc0b5..ac403d4a6d 100644 --- a/github/tests/Organization.py +++ b/github/tests/Organization.py @@ -8,9 +8,10 @@ # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # -# Copyright 2017 Balázs Rostás # +# Copyright 2017 Balázs Rostás # # Copyright 2018 Anton Nguyen # # Copyright 2018 sfdye # +# Copyright 2018 Jacopo Notarstefano # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # @@ -47,6 +48,7 @@ def testAttributes(self): self.assertEqual(self.org.collaborators, 9) self.assertEqual(self.org.company, None) self.assertEqual(self.org.created_at, datetime.datetime(2014, 1, 9, 16, 56, 17)) + self.assertEqual(self.org.description, 'BeaverSoftware writes software.') self.assertEqual(self.org.disk_usage, 2) self.assertEqual(self.org.email, '') self.assertEqual(self.org.followers, 0) @@ -93,10 +95,11 @@ def testEditWithoutArguments(self): self.org.edit() def testEditWithAllArguments(self): - self.org.edit("BeaverSoftware2@vincent-jacques.net", "http://vincent-jacques.net", "Company edited by PyGithub", "BeaverSoftware2@vincent-jacques.net", "Location edited by PyGithub", "Name edited by PyGithub") + self.org.edit("BeaverSoftware2@vincent-jacques.net", "http://vincent-jacques.net", "Company edited by PyGithub", "Description edited by PyGithub", "BeaverSoftware2@vincent-jacques.net", "Location edited by PyGithub", "Name edited by PyGithub") self.assertEqual(self.org.billing_email, "BeaverSoftware2@vincent-jacques.net") self.assertEqual(self.org.blog, "http://vincent-jacques.net") self.assertEqual(self.org.company, "Company edited by PyGithub") + self.assertEqual(self.org.description, "Description edited by PyGithub") self.assertEqual(self.org.email, "BeaverSoftware2@vincent-jacques.net") self.assertEqual(self.org.location, "Location edited by PyGithub") self.assertEqual(self.org.name, "Name edited by PyGithub") diff --git a/github/tests/ReplayData/Organization.testEditWithAllArguments.txt b/github/tests/ReplayData/Organization.testEditWithAllArguments.txt index 4919af1335..90364d265f 100644 --- a/github/tests/ReplayData/Organization.testEditWithAllArguments.txt +++ b/github/tests/ReplayData/Organization.testEditWithAllArguments.txt @@ -4,8 +4,8 @@ api.github.com None /orgs/BeaverSoftware {'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} -{"name": "Name edited by PyGithub", "billing_email": "BeaverSoftware2@vincent-jacques.net", "company": "Company edited by PyGithub", "blog": "http://vincent-jacques.net", "location": "Location edited by PyGithub", "email": "BeaverSoftware2@vincent-jacques.net"} +{"name": "Name edited by PyGithub", "billing_email": "BeaverSoftware2@vincent-jacques.net", "company": "Company edited by PyGithub", "blog": "http://vincent-jacques.net", "location": "Location edited by PyGithub", "email": "BeaverSoftware2@vincent-jacques.net", "description": "Description edited by PyGithub"} 200 [('status', '200 OK'), ('x-ratelimit-remaining', '4992'), ('content-length', '833'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"fe61098c87e054abfa5626e6a76bbcbd"'), ('date', 'Sat, 26 May 2012 20:50:35 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"public_gists":0,"type":"Organization","disk_usage":112,"private_gists":0,"public_repos":2,"url":"https://api.github.com/orgs/BeaverSoftware","total_private_repos":0,"plan":{"private_repos":0,"name":"free","space":307200},"blog":"http://vincent-jacques.net","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","owned_private_repos":0,"collaborators":0,"company":"Company edited by PyGithub","login":"BeaverSoftware","email":"BeaverSoftware2@vincent-jacques.net","followers":0,"name":"Name edited by PyGithub","created_at":"2012-02-09T19:20:12Z","location":"Location edited by PyGithub","id":1424031,"billing_email":"BeaverSoftware2@vincent-jacques.net","following":0,"html_url":"https://github.com/BeaverSoftware"} +{"public_gists":0,"type":"Organization","disk_usage":112,"private_gists":0,"public_repos":2,"url":"https://api.github.com/orgs/BeaverSoftware","total_private_repos":0,"plan":{"private_repos":0,"name":"free","space":307200},"blog":"http://vincent-jacques.net","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","owned_private_repos":0,"collaborators":0,"company":"Company edited by PyGithub","login":"BeaverSoftware","email":"BeaverSoftware2@vincent-jacques.net","followers":0,"name":"Name edited by PyGithub","created_at":"2012-02-09T19:20:12Z","location":"Location edited by PyGithub","id":1424031,"billing_email":"BeaverSoftware2@vincent-jacques.net","following":0,"html_url":"https://github.com/BeaverSoftware", "description": "Description edited by PyGithub"}