From 19fc43abf6c80720a7f69471ae41b2eba0daa363 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Thu, 21 May 2020 09:59:05 +1000 Subject: [PATCH] PullRequestReview is not a completable object (#1528) While chasing coverage failures, I discovered PullRequestReview's do not send back a URL at all, which means firstly, the url property is not required because it will always be None, and secondly, the object can never be completed. I'm not certain why this change broke the test, but it looked brittle, refactor it to be clearer. --- github/PullRequestReview.py | 21 +-------------------- tests/PullRequestReview.py | 2 +- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/github/PullRequestReview.py b/github/PullRequestReview.py index 59f603b1..c0a93581 100644 --- a/github/PullRequestReview.py +++ b/github/PullRequestReview.py @@ -30,7 +30,7 @@ import github.GithubObject import github.NamedUser -class PullRequestReview(github.GithubObject.CompletableGithubObject): +class PullRequestReview(github.GithubObject.NonCompletableGithubObject): """ This class represents PullRequestReviews. The reference can be found here https://developer.github.com/v3/pulls/reviews/ """ @@ -43,7 +43,6 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): """ :type: integer """ - self._completeIfNotSet(self._id) return self._id.value @property @@ -51,7 +50,6 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): """ :type: :class:`github.NamedUser.NamedUser` """ - self._completeIfNotSet(self._user) return self._user.value @property @@ -59,7 +57,6 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): """ :type: string """ - self._completeIfNotSet(self._body) return self._body.value @property @@ -67,7 +64,6 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): """ :type: string """ - self._completeIfNotSet(self._commit_id) return self._commit_id.value @property @@ -75,23 +71,13 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): """ :type: string """ - self._completeIfNotSet(self._state) return self._state.value - @property - def url(self): - """ - :type: string - """ - self._completeIfNotSet(self._url) - return self._url.value - @property def html_url(self): """ :type: string """ - self._completeIfNotSet(self._html_url) return self._html_url.value @property @@ -99,7 +85,6 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): """ :type: string """ - self._completeIfNotSet(self._pull_request_url) return self._pull_request_url.value @property @@ -107,7 +92,6 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): """ :type: datetime.datetime """ - self._completeIfNotSet(self._submitted_at) return self._submitted_at.value def dismiss(self, message): @@ -129,7 +113,6 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): self._body = github.GithubObject.NotSet self._commit_id = github.GithubObject.NotSet self._state = github.GithubObject.NotSet - self._url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._pull_request_url = github.GithubObject.NotSet self._submitted_at = github.GithubObject.NotSet @@ -147,8 +130,6 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject): self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) - if "url" in attributes: # pragma no branch - self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "pull_request_url" in attributes: # pragma no branch diff --git a/tests/PullRequestReview.py b/tests/PullRequestReview.py index 995c7461..bfda0634 100644 --- a/tests/PullRequestReview.py +++ b/tests/PullRequestReview.py @@ -76,7 +76,7 @@ class PullRequestReview(Framework.TestCase): self.assertEqual( self.pullreview.submitted_at, datetime.datetime(2017, 3, 22, 19, 6, 59) ) - self.assertIn(self.created_pullreview, self.pullreviews) + self.assertIn(self.created_pullreview.id, [r.id for r in self.pullreviews]) self.assertEqual( repr(self.pullreview), 'PullRequestReview(user=NamedUser(login="jzelinskie"), id=28482091)',