From: Harmon Date: Fri, 7 Jan 2022 08:07:08 +0000 (-0600) Subject: Add documentation and test for Client.get_me X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=62b5b586e75a850427eabdf31448d73a9e564f66;p=tweepy.git Add documentation and test for Client.get_me --- diff --git a/cassettes/test_get_me.yaml b/cassettes/test_get_me.yaml new file mode 100644 index 0000000..5765b03 --- /dev/null +++ b/cassettes/test_get_me.yaml @@ -0,0 +1,69 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.10.0 Requests/2.27.1 Tweepy/4.4.0 + method: GET + uri: https://api.twitter.com/2/users/me + response: + body: + string: !!binary | + H4sIAAAAAAAAAKpWSkksSVSyqlbKTFGyUjI0MDcyMjUwNTYyMzG1tLQwtTRT0lHKS8xNBUqGlKem + FlQqhKQWl2TmpQPFS4tTi1DkXFLLlGprAQAAAP//AwBsn+W8VAAAAA== + headers: + api-version: + - '2.32' + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '97' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 07 Jan 2022 08:05:56 UTC + server: + - tsa_b + set-cookie: + - guest_id_marketing=v1%3A164154275647329260; Max-Age=63072000; Expires=Sun, + 07 Jan 2024 08:05:56 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id_ads=v1%3A164154275647329260; Max-Age=63072000; Expires=Sun, 07 Jan + 2024 08:05:56 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - personalization_id="v1_ihenaUbNvkcvFbDMb0HZ4g=="; Max-Age=63072000; Expires=Sun, + 07 Jan 2024 08:05:56 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A164154275647329260; Max-Age=63072000; Expires=Sun, 07 Jan 2024 + 08:05:56 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read-write-directmessages + x-connection-hash: + - 387c0d90998be5164939411741317edc2ba8d97f40d6722aeac473c4a50c6d58 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '75' + x-rate-limit-remaining: + - '74' + x-rate-limit-reset: + - '1641543656' + x-response-time: + - '36' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/docs/client.rst b/docs/client.rst index bf0bc4b..b6dc18f 100644 --- a/docs/client.rst +++ b/docs/client.rst @@ -108,6 +108,8 @@ +--------------------------------------------------------------+----------------------------------------+ | `GET /2/users/by`_ | :meth:`Client.get_users` | +--------------------------------------------------------------+----------------------------------------+ + | `GET /2/users/me`_ | :meth:`Client.get_me` | + +--------------------------------------------------------------+----------------------------------------+ | .. centered:: :ref:`Spaces` | +-------------------------------------------------------------------------------------------------------+ | .. centered:: |Search Spaces|_ | @@ -227,6 +229,7 @@ .. _GET /2/users/by/username/:username: https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by-username-username .. _GET /2/users: https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users .. _GET /2/users/by: https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by +.. _GET /2/users/me: https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-me .. |Search Spaces| replace:: *Search Spaces* .. _GET /2/spaces/search: https://developer.twitter.com/en/docs/twitter-api/spaces/search/api-reference/get-spaces-search .. |Spaces lookup| replace:: *Spaces lookup* @@ -370,6 +373,8 @@ User lookup .. automethod:: Client.get_users +.. automethod:: Client.get_me + Spaces ====== diff --git a/tests/test_client.py b/tests/test_client.py index 02ebed8..f44e8fb 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -131,6 +131,10 @@ class TweepyTestCase(unittest.TestCase): def test_get_users(self): self.client.get_users(usernames=["Twitter", "TwitterDev"]) + @tape.use_cassette("test_get_me.yaml", serializer="yaml") + def test_get_me(self): + self.client.get_me(user_auth=True) + @tape.use_cassette("test_search_spaces.yaml", serializer="yaml") def test_search_spaces(self): self.client.search_spaces("Twitter")