Adds the 'twitter_username' attribute to NamedUser. (#1585)

* Adds the 'twitter_username' attribute to NamedUser.
This commit is contained in:
Daniel Haas
2020-06-27 14:43:48 +10:00
committed by GitHub
parent 1879518e2b
commit 079f75a726
4 changed files with 18 additions and 1 deletions
+13
View File
@@ -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
+2
View File
@@ -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: ...
+2
View File
@@ -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==")
@@ -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"}