From d2ab6377fb76593bb12670281ced0f659189e54b Mon Sep 17 00:00:00 2001 From: Hanaasagi Date: Tue, 15 Jun 2021 18:49:55 +0000 Subject: [PATCH] closes #1971; Add two_factor_authentication in AuthenticatedUser. --- github/AuthenticatedUser.py | 13 +++++++++++++ github/AuthenticatedUser.pyi | 2 ++ tests/AuthenticatedUser.py | 1 + .../ReplayData/AuthenticatedUser.testAttributes.txt | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/github/AuthenticatedUser.py b/github/AuthenticatedUser.py index 9f9993d56a..c66b9a53c2 100644 --- a/github/AuthenticatedUser.py +++ b/github/AuthenticatedUser.py @@ -367,6 +367,14 @@ def url(self): self._completeIfNotSet(self._url) return self._url.value + @property + def two_factor_authentication(self): + """ + :type: bool + """ + self._completeIfNotSet(self._two_factor_authentication) + return self._two_factor_authentication.value + def add_to_emails(self, *emails): """ :calls: `POST /user/emails `_ @@ -1369,6 +1377,7 @@ def _initAttributes(self): self._type = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet + self._two_factor_authentication = github.GithubObject.NotSet def _useAttributes(self, attributes): if "avatar_url" in attributes: # pragma no branch @@ -1455,3 +1464,7 @@ def _useAttributes(self, attributes): self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) + if "two_factor_authentication" in attributes: + self._two_factor_authentication = self._makeBoolAttribute( + attributes["two_factor_authentication"] + ) diff --git a/github/AuthenticatedUser.pyi b/github/AuthenticatedUser.pyi index b6832b48d9..fa730b2f1a 100644 --- a/github/AuthenticatedUser.pyi +++ b/github/AuthenticatedUser.pyi @@ -226,3 +226,5 @@ class AuthenticatedUser(CompletableGithubObject): def updated_at(self) -> datetime: ... @property def url(self) -> str: ... + @property + def two_factor_authentication(self) -> bool: ... diff --git a/tests/AuthenticatedUser.py b/tests/AuthenticatedUser.py index ac32251cfa..61edafe77b 100644 --- a/tests/AuthenticatedUser.py +++ b/tests/AuthenticatedUser.py @@ -76,6 +76,7 @@ def testAttributes(self): self.assertEqual(self.user.url, "https://api.github.com/users/jacquev6") self.assertEqual(self.user.node_id, "MDQ6VXNlcjMyNzE0Ng==") self.assertEqual(repr(self.user), 'AuthenticatedUser(login="jacquev6")') + self.assertTrue(self.user.two_factor_authentication) def testEditWithoutArguments(self): self.user.edit() diff --git a/tests/ReplayData/AuthenticatedUser.testAttributes.txt b/tests/ReplayData/AuthenticatedUser.testAttributes.txt index a87a08687b..d1e0c2d7d7 100644 --- a/tests/ReplayData/AuthenticatedUser.testAttributes.txt +++ b/tests/ReplayData/AuthenticatedUser.testAttributes.txt @@ -7,5 +7,5 @@ None None 200 [('status', '200 OK'), ('x-ratelimit-remaining', '4994'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"79f748546e5fc4492505a70de6542183"'), ('date', 'Tue, 08 May 2012 09:51:20 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"public_repos":10,"type":"User","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","followers":13,"bio":"","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","disk_usage":16692,"plan":{"private_repos":5,"space":614400,"name":"micro","collaborators":1},"html_url":"https://github.com/jacquev6","blog":"http://vincent-jacques.net","login":"jacquev6","email":"vincent@vincent-jacques.net","created_at":"2010-07-09T06:10:06Z","company":"Criteo","location":"Paris, France","total_private_repos":5,"public_gists":1,"following":24,"name":"Vincent Jacques","id":327146,"owned_private_repos":5,"private_gists":5,"collaborators":0,"hireable":false,"node_id":"MDQ6VXNlcjMyNzE0Ng=="} +{"public_repos":10,"type":"User","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","followers":13,"bio":"","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","disk_usage":16692,"plan":{"private_repos":5,"space":614400,"name":"micro","collaborators":1},"html_url":"https://github.com/jacquev6","blog":"http://vincent-jacques.net","login":"jacquev6","email":"vincent@vincent-jacques.net","created_at":"2010-07-09T06:10:06Z","company":"Criteo","location":"Paris, France","total_private_repos":5,"public_gists":1,"following":24,"name":"Vincent Jacques","id":327146,"owned_private_repos":5,"private_gists":5,"collaborators":0,"hireable":false,"node_id":"MDQ6VXNlcjMyNzE0Ng==","two_factor_authentication":true}