From b91dee8df6afe98882383dc79d9bd1c300bc474a Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 15 Aug 2018 13:39:08 +1000 Subject: [PATCH] Revert "Remove NamedUser.contributions (#774)" (#865) This reverts commit a519e4675a911a3f20f1ad197cbbbb14bdd1842d. NamedUser.contributions can be populated, so we should fill in the data. Fixes #850 --- github/NamedUser.py | 11 +++++++++++ github/tests/Repository.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/github/NamedUser.py b/github/NamedUser.py index f3e815b1..c74b6064 100644 --- a/github/NamedUser.py +++ b/github/NamedUser.py @@ -101,6 +101,14 @@ class NamedUser(github.GithubObject.CompletableGithubObject): self._completeIfNotSet(self._company) return self._company.value + @property + def contributions(self): + """ + :type: integer + """ + self._completeIfNotSet(self._contributions) + return self._contributions.value + @property def created_at(self): """ @@ -563,6 +571,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): self._blog = github.GithubObject.NotSet self._collaborators = github.GithubObject.NotSet self._company = github.GithubObject.NotSet + self._contributions = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._disk_usage = github.GithubObject.NotSet self._email = github.GithubObject.NotSet @@ -607,6 +616,8 @@ class NamedUser(github.GithubObject.CompletableGithubObject): self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "company" in attributes: # pragma no branch self._company = self._makeStringAttribute(attributes["company"]) + if "contributions" in attributes: # pragma no branch + self._contributions = self._makeIntAttribute(attributes["contributions"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "disk_usage" in attributes: # pragma no branch diff --git a/github/tests/Repository.py b/github/tests/Repository.py index a1b5a988..677f0372 100644 --- a/github/tests/Repository.py +++ b/github/tests/Repository.py @@ -110,7 +110,7 @@ class Repository(Framework.TestCase): repo.delete() def testGetContributors(self): - self.assertListKeyEqual(self.repo.get_contributors(), lambda c: c.login, ["jacquev6"]) + self.assertListKeyEqual(self.repo.get_contributors(), lambda c: (c.login, c.contributions), [("jacquev6", 355)]) def testCreateMilestone(self): milestone = self.repo.create_milestone("Milestone created by PyGithub", state="open", description="Description created by PyGithub", due_on=datetime.date(2012, 6, 15))