diff --git a/github/NamedUser.py b/github/NamedUser.py index 44d41b88..990c513a 100644 --- a/github/NamedUser.py +++ b/github/NamedUser.py @@ -68,6 +68,14 @@ class NamedUser(github.GithubObject.CompletableGithubObject): self._completeIfNotSet(self._node_id) return self._node_id.value + @property + def twitter_username(self): + """ + :type: string + """ + self._completeIfNotSet(self._twitter_username) + return self._twitter_username.value + def __hash__(self): return hash((self.id, self.login)) @@ -681,6 +689,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): self._suspended_at = github.GithubObject.NotSet self._team_count = github.GithubObject.NotSet self._total_private_repos = github.GithubObject.NotSet + self._twitter_username = github.GithubObject.NotSet self._type = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet @@ -784,6 +793,10 @@ class NamedUser(github.GithubObject.CompletableGithubObject): self._total_private_repos = self._makeIntAttribute( attributes["total_private_repos"] ) + if "twitter_username" in attributes: # pragma no branch + self._twitter_username = self._makeStringAttribute( + attributes["twitter_username"] + ) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch diff --git a/github/NamedUser.pyi b/github/NamedUser.pyi index d180e59e..b41a0584 100644 --- a/github/NamedUser.pyi +++ b/github/NamedUser.pyi @@ -128,6 +128,8 @@ class NamedUser(CompletableGithubObject): @property def total_private_repos(self) -> Optional[int]: ... @property + def twitter_username(self) -> str: ... + @property def type(self) -> str: ... @property def updated_at(self) -> datetime: ... diff --git a/tests/NamedUser.py b/tests/NamedUser.py index 52099f2f..3f12e602 100644 --- a/tests/NamedUser.py +++ b/tests/NamedUser.py @@ -72,6 +72,7 @@ class NamedUser(Framework.TestCase): self.assertEqual(self.user.public_repos, 61) self.assertEqual(self.user.suspended_at, None) self.assertEqual(self.user.total_private_repos, None) + self.assertEqual(self.user.twitter_username, "nvie") self.assertEqual(self.user.type, "User") self.assertEqual(self.user.url, "https://api.github.com/users/nvie") self.assertEqual(self.user.node_id, "MDQ6VXNlcjgzODQ0") @@ -110,6 +111,7 @@ class NamedUser(Framework.TestCase): self.user.suspended_at, datetime.datetime(2013, 8, 10, 7, 11, 7) ) self.assertEqual(self.user.total_private_repos, 5) + self.assertIsNone(self.user.twitter_username) self.assertEqual(self.user.type, "User") self.assertEqual(self.user.url, "https://api.github.com/users/jacquev6") self.assertEqual(self.user.node_id, "MDQ6VXNlcjMyNzE0Ng==") diff --git a/tests/ReplayData/NamedUser.testAttributesOfOtherUser.txt b/tests/ReplayData/NamedUser.testAttributesOfOtherUser.txt index a47e7989..fd95b101 100644 --- a/tests/ReplayData/NamedUser.testAttributesOfOtherUser.txt +++ b/tests/ReplayData/NamedUser.testAttributesOfOtherUser.txt @@ -7,5 +7,5 @@ None None 200 [('status', '200 OK'), ('x-ratelimit-remaining', '4994'), ('content-length', '598'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"66a516a2007fb7df8bbb3f9cc7cb2da8"'), ('date', 'Fri, 18 May 2012 19:46:37 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"public_gists":16,"type":"User","hireable":false,"company":"3rd Cloud","url":"https://api.github.com/users/nvie","gravatar_id":"c5a7f21b46df698f3db31c37ed0cf55a","bio":null,"followers":296,"blog":"http://nvie.com","avatar_url":"https://secure.gravatar.com/avatar/c5a7f21b46df698f3db31c37ed0cf55a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"nvie","email":"vincent@3rdcloud.com","public_repos":61,"html_url":"https://github.com/nvie","name":"Vincent Driessen","created_at":"2009-05-12T21:19:38Z","location":"Netherlands","id":83844,"following":41,"node_id":"MDQ6VXNlcjgzODQ0"} +{"public_gists":16,"type":"User","hireable":false,"company":"3rd Cloud","url":"https://api.github.com/users/nvie","gravatar_id":"c5a7f21b46df698f3db31c37ed0cf55a","bio":null,"followers":296,"blog":"http://nvie.com","avatar_url":"https://secure.gravatar.com/avatar/c5a7f21b46df698f3db31c37ed0cf55a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"nvie","email":"vincent@3rdcloud.com","public_repos":61,"html_url":"https://github.com/nvie","name":"Vincent Driessen","created_at":"2009-05-12T21:19:38Z","location":"Netherlands","id":83844,"following":41,"node_id":"MDQ6VXNlcjgzODQ0","twitter_username":"nvie"}