Add documentation and test for Client.get_me
authorHarmon <Harmon758@gmail.com>
Fri, 7 Jan 2022 08:07:08 +0000 (02:07 -0600)
committerHarmon <Harmon758@gmail.com>
Fri, 7 Jan 2022 08:07:08 +0000 (02:07 -0600)
cassettes/test_get_me.yaml [new file with mode: 0644]
docs/client.rst
tests/test_client.py

diff --git a/cassettes/test_get_me.yaml b/cassettes/test_get_me.yaml
new file mode 100644 (file)
index 0000000..5765b03
--- /dev/null
@@ -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
index bf0bc4bd083c1b96a5db0ad5492174fb94027797..b6dc18f1e55cac1f4e9d7e7682f3a0f8a61f28a4 100644 (file)
     +--------------------------------------------------------------+----------------------------------------+
     | `GET /2/users/by`_                                           | :meth:`Client.get_users`               |
     +--------------------------------------------------------------+----------------------------------------+
+    | `GET /2/users/me`_                                           | :meth:`Client.get_me`                  |
+    +--------------------------------------------------------------+----------------------------------------+
     | .. centered:: :ref:`Spaces`                                                                           |
     +-------------------------------------------------------------------------------------------------------+
     | .. centered:: |Search Spaces|_                                                                        |
 .. _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
 ======
 
index 02ebed82bc42193d257d1c895bdba0ae908c2de2..f44e8fb91e76fcdf9705a5bf59b1a2a5e5c43c2d 100644 (file)
@@ -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")