From b84348e66c30ef1de1e5b955722185d7b765e740 Mon Sep 17 00:00:00 2001 From: Harmon Date: Mon, 12 Apr 2021 23:04:09 -0500 Subject: [PATCH] Add tests for Client --- cassettes/test_follow_and_unfollow.yaml | 128 +++++++++++++++++++++ cassettes/test_get_tweet.yaml | 66 +++++++++++ cassettes/test_get_tweets.yaml | 68 +++++++++++ cassettes/test_get_user.yaml | 61 ++++++++++ cassettes/test_get_users.yaml | 63 +++++++++++ cassettes/test_get_users_followers.yaml | 120 ++++++++++++++++++++ cassettes/test_get_users_following.yaml | 81 +++++++++++++ cassettes/test_get_users_mentions.yaml | 77 +++++++++++++ cassettes/test_get_users_tweets.yaml | 71 ++++++++++++ cassettes/test_hide_and_unhide_reply.yaml | 131 ++++++++++++++++++++++ cassettes/test_search_recent_tweets.yaml | 79 +++++++++++++ docs/running_tests.rst | 1 + setup.cfg | 2 +- tests/config.py | 14 ++- tests/test_client.py | 72 ++++++++++++ 15 files changed, 1027 insertions(+), 7 deletions(-) create mode 100644 cassettes/test_follow_and_unfollow.yaml create mode 100644 cassettes/test_get_tweet.yaml create mode 100644 cassettes/test_get_tweets.yaml create mode 100644 cassettes/test_get_user.yaml create mode 100644 cassettes/test_get_users.yaml create mode 100644 cassettes/test_get_users_followers.yaml create mode 100644 cassettes/test_get_users_following.yaml create mode 100644 cassettes/test_get_users_mentions.yaml create mode 100644 cassettes/test_get_users_tweets.yaml create mode 100644 cassettes/test_hide_and_unhide_reply.yaml create mode 100644 cassettes/test_search_recent_tweets.yaml create mode 100644 tests/test_client.py diff --git a/cassettes/test_follow_and_unfollow.yaml b/cassettes/test_follow_and_unfollow.yaml new file mode 100644 index 0000000..910eb96 --- /dev/null +++ b/cassettes/test_follow_and_unfollow.yaml @@ -0,0 +1,128 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: DELETE + uri: https://api.twitter.com/2/users/1072250532645998596/following/783214 + response: + body: + string: !!binary | + H4sIAAAAAAAAAKpWSkksSVSyqlZKy8/JyS/PzEtXskpLzClOra0FAAAA//8DAMXGczccAAAA + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '54' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:49:50 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_bro8VRa9TVemchH8zXuREQ=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:49:50 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828579072987002; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:49:50 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read-write-directmessages + x-connection-hash: + - 1dbe7a102ae9486c2f9d34a19d8213d9 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '50' + x-rate-limit-remaining: + - '49' + x-rate-limit-reset: + - '1618286690' + x-response-time: + - '52' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +- request: + body: '{"target_user_id": "783214"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '28' + Content-Type: + - application/json + Cookie: + - guest_id=v1%3A161828579072987002; personalization_id="v1_bro8VRa9TVemchH8zXuREQ==" + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: POST + uri: https://api.twitter.com/2/users/1072250532645998596/following + response: + body: + string: !!binary | + H4sIAAAAAAAAAKpWSkksSVSyqlZKy8/JyS/PzEtXsiopKk3VUSpIzUsBcuMhEkpWaYk5xam1tQAA + AAD//wMALpT8ejIAAAA= + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '71' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:49:50 GMT + server: + - tsa_b + strict-transport-security: + - max-age=631138519 + x-access-level: + - read-write-directmessages + x-connection-hash: + - 1dbe7a102ae9486c2f9d34a19d8213d9 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '50' + x-rate-limit-remaining: + - '49' + x-rate-limit-reset: + - '1618286690' + x-response-time: + - '51' + x-tsa-request-body-time: + - '5' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_get_tweet.yaml b/cassettes/test_get_tweet.yaml new file mode 100644 index 0000000..c602689 --- /dev/null +++ b/cassettes/test_get_tweet.yaml @@ -0,0 +1,66 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/tweets/1293593516040269825 + response: + body: + string: !!binary | + H4sIAAAAAAAAAFSOwU6DQBCGX2VcrwYKtA3lRlI11YtJ1V64LOwU1iy7ZJkFSdPE1/D1fBIX4sVk + ModvvvzzX5jgxFl2YVKwjEXxLtn4ibar9Sre7tJ4w+4Y4Sf544F+vr57OEvNlZqgQYs3ULh9mtz7 + vV9HcOQzVsoA+WkQNI5w+zpKIrT5yyEodKFP6GMsgsXSSSWkrhf1zwKvwRDD2Zp24bU1Tgtw3ZxZ + 4uL0aAcE4ywIHFCZzrPKtK3TkqYAcu+TEXxa+irudNWA7MFoX3vOLLGWWvvPS6GGqOuzMKSgMmES + v9uxe+RPI/zjz/zhWH6c3vKUXa+/AAAA//8DAF869jI2AQAA + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '264' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:45:04 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_CR3Pk00ylbnJA+U0ny6uGQ=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:45:04 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828550441263991; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:45:04 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - 93589af46001ea987bd7aa7363e12bb3 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '300' + x-rate-limit-remaining: + - '299' + x-rate-limit-reset: + - '1618286404' + x-response-time: + - '50' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_get_tweets.yaml b/cassettes/test_get_tweets.yaml new file mode 100644 index 0000000..4484310 --- /dev/null +++ b/cassettes/test_get_tweets.yaml @@ -0,0 +1,68 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/tweets?ids=1293593516040269825%2C1293595870563381249 + response: + body: + string: !!binary | + H4sIAAAAAAAAAFRQy07CQBT9lcuwJTxaCqW7GtCgGw0IC3Ex7dzCmDLTzKOVEBJ/w9/zS5w2RGly + M4szJ+d1JowaSqK3M+GMRGTkzfzA3WgyHA+9ySz0AtIjBj+N+1yan69vDRkXNM9PcECFHdjZeegv + 3Dsfj2BFazjPJRh3BwSBFXTXFTcGVfy87O/ETmzRySgEhYnlOeNi31CvLHA0KD3IlDw2+F5JKxjY + otZMsOFoVCWCtAoYlpjLwmGpPB6t4ObUh9jxjWT01OTNqRXpAbgGKVzsWjPBPRfCOTeBDsYUOhoM + TD+VA9/bqKp4oI8VtPAner9KPravcUguvdZaQTgdBhPfD0feePa/VrtPBAuqnHucpqi1654j1chq + +3WdFCoEKoSrmiJrc69TZlxpAyhYIbkwrkz2t/CNVadWvFkcuo3WVaq7QaW5FHf2WLTr7aelT3GZ + mBdyeb/8AgAA//8DADmclNgXAgAA + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:47:51 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_I4pPzi3RhJuWUOrZMV196A=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:47:51 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828567137532771; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:47:51 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - e73d97435f0dceb85177cf88d0b7e5e6 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '300' + x-rate-limit-remaining: + - '299' + x-rate-limit-reset: + - '1618286571' + x-response-time: + - '64' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_get_user.yaml b/cassettes/test_get_user.yaml new file mode 100644 index 0000000..b28f0de --- /dev/null +++ b/cassettes/test_get_user.yaml @@ -0,0 +1,61 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/users/by/username/Twitter + response: + body: + string: !!binary | + H4sIAAAAAAAAAKpWSkksSVSyqlbKTFGyUjK3MDYyNFHSUcpLzE0F8kPKM0tKUouAAqXFqUVogrW1 + AAAAAP//AwDiU9YFPgAAAA== + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '73' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:53:58 UTC + server: + - tsa_devel + set-cookie: + - personalization_id="v1_hqeHOrpZtpMV+obFvsh9Iw=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:53:58 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828603844806570; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:53:58 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - 0c5529d5329fbdc8c50561a632ba70f1d7e2c3030c8b2bda01f041b9ee98241b + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '300' + x-rate-limit-remaining: + - '299' + x-rate-limit-reset: + - '1618286938' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_get_users.yaml b/cassettes/test_get_users.yaml new file mode 100644 index 0000000..d35f9be --- /dev/null +++ b/cassettes/test_get_users.yaml @@ -0,0 +1,63 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/users/by?usernames=Twitter%2CTwitterDev + response: + body: + string: !!binary | + H4sIAAAAAAAAAKpWSkksSVSyiq5WykxRslIytzA2MjRR0lHKS8xNBfJDyjNLSlKLgAKlxalFaIK1 + OlBdRkYmJpaWJpYmphg6FVxSy7DqBonXxtYCAAAA//8DAEWiGEiBAAAA + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '99' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:53:58 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_lJ3zeHQX9GMUwI+LAGNc2w=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:53:58 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828603874568586; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:53:58 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - b6daff7e518613c6389555b2a178a358 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '300' + x-rate-limit-remaining: + - '299' + x-rate-limit-reset: + - '1618286938' + x-response-time: + - '30' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_get_users_followers.yaml b/cassettes/test_get_users_followers.yaml new file mode 100644 index 0000000..83345a8 --- /dev/null +++ b/cassettes/test_get_users_followers.yaml @@ -0,0 +1,120 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/users/783214/followers + response: + body: + string: !!binary | + H4sIAAAAAAAAAGxZS28cxxH+K2OebMAxerqnH+NTluRKJMWHwpVlW0mwaO6OOM3dmaHnIXHlGJCc + GDAQGwECJIgDB8iBhoMghnPIwTnYAfIr7BtBJQ7gi/9Cvp6ltN1Ng+RwWdWsra6u+uqr3rfXprrV + a6/+9O01M117dS1mUqSpigWTDL9lKtK1l9dKXWRQ3tOXjz8qdG0g6pqsfi62slQmaSxEvPbOy89t + qRiWFJGUEx4rQsnK1klV6vwt0/mmnkk9K5JTFic8FUQyRmBzZeXNrjbRYWaaaDOLRlX3SPv2rN6q + NzOrpKFvCRE0JookaRLHK6uDuZkYHe3p+aTy7S01S4VjiyepZDQhMMoQQJKsbA13ozt5Vp3mZt41 + lx998v0Xv/lZt6nYBp43yA3ffDYft88XeyEgKVOCUZwIl4pJunqD0SKbRjfzbq6LaK/KTTedmjL6 + iZ6Gx2QXLtdhWcwd83EqW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IJqheFLiCJ7X0ABjMnS3tmGtx6UUCPRZtwL9M4xwNAacE + CgtkcNnPj0evbb0+uL01uBPsqQNeneYhwQAU95dFyEjGXXcGzcOQcDbdaVYXWpfl2CXS4M4cfAdk + AM1XuuPgPZ1nQIKFnkaDea6bvLj2aRQWWL2HVAqdDvxY4rwSHKWTQscViPhRFbK7m5CsW6l70Wc5 + NlgJIQk6jnS7xDfBMDd6Pbm5++b+G945x/bzMUbtB1lgjW497S90Y/R4L5u3YV0VvWxc9iv8ssB4 + hBglMQZm8AG3PLO6XmDYyloU/sEcJx404aWqX+ZM8pjf7EUmgs4QKM6cXq7HFiiq+1M0z6qcBiDC + AmUAcVSBqYAm25nTKZTTPd2E94+FFY1dhkHtHS9TcI7bsUoy7wKzXAR1tl0shSHKgnwBaAVLvHES + hO+om6IbR5uYx8oTvQg/BHq2oNc7NCq1H24R8DikOJWWvbjTjG/koZ6R1N5IxOGno0ShNQG0SYIk + T92NHT8w1725EicUNZaKxC/fNE4Q5TRWVKIFOO4cjH60Oby7vStfeME3V02zcXNa1a17FSMxAKGp + g2IRoaR3FVMbM9H1tIrmmSXdUaPLSZD2kOz2ymsHILkACYGHzDW502HuwaiGQbE28/BTjivtlRKg + +fOXEVz7efXba3XWdPN2PKm6sl17FbkFm9lZO26rWVbif/nGiByQDbG9LeLhvXv31t555/8AAAD/ + /wMAqoDR0e0eAAA= + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '3317' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:51:13 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_qI6DciZXKvhii33vvYpxkA=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:51:13 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828587363409374; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:51:13 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - 39d89ad5bca8fa88cbc06044d2cf9c7b + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '15' + x-rate-limit-remaining: + - '14' + x-rate-limit-reset: + - '1618286773' + x-response-time: + - '102' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_get_users_following.yaml b/cassettes/test_get_users_following.yaml new file mode 100644 index 0000000..96f647b --- /dev/null +++ b/cassettes/test_get_users_following.yaml @@ -0,0 +1,81 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/users/783214/following + response: + body: + string: !!binary | + H4sIAAAAAAAAAGxWz0/cRhT+V0bbSyJBmBmPPWNuGwiNKCBSUCn9odWwHtYD3vFqbGdlKFIPPVSt + lPYSiQNpc6iUC1J7qdpc+t8gomj5H/q8UDzj5rIrvR+f3/ve95592ktkKXvLX572dNJb7vFAECKY + 4IRSRmL46y30jBwr8O1OdVkqi/qFlqYAe1Uo6/vuXGcLd3ABj2OBCY9alD1lkhptVH7+tLFm1dTq + Ujn5hFEuIiza9HV1eIj2pRn5+bnVI21kVky0cdIjjEMa4ja9b0a2vu0AbUrjg8jGKRvfWHooAeMx + Ji3KqDJG2jzLpA/g2J1sLoJYOC1sW6VKjVbSVB8cKOtD2MoAlWlxrE9OlHWp4BGNwtCpYs1Kc4x2 + 0jrvsnHYeIpbRwsgMA8wj1sAZfUQlXnS6WJucdIECRnjbdqWHuaZQquVGQ07qSa5Nd5n05AJRqgz + /z4QZNBOqabSlov9tDODIh+rA5noREmneRoJgQHJaV5OT7REm9qedMtP1SE422QuYhaFGLsiMqb+ + gIqOGnsN5vK5QwDmHHREwjZ/Uw9TlQEHn+gxelCkailV9qGPNT4a30Ud67GDRgWIgcUOn8fSKoPS + rhrn5jr1lMhojENGnVL6ehGqRtt53tGyBvMErI4QKWEYB9TnAX2DPlVyMrH5xGpZqo4cPVc7D4Jp + IECOLdaGzrIaLS2hjzYgdA80PLf4cLemFobCYAHJmeu6VItP5ZzY92+/nf1yefPy3Mf4OO9PZd08 + AGIdrCCIcUQi8oExbahOW6mq/5tOplyQiDOOKXW2FSoZ12g3VQ3HaWdEjQ/0Nmk87dHDgvMYds3p + CqS6C0tjSm06gzoCZu89LQYJoR0cuIsDRymR6KtqVQSr8PtE4M7yjapamYGcxzlQDIewPe4V3JG2 + QuuylrYJ9lEaX+tqUUSIAyFih95+ohpuQd2+8hrz48wVfRBHJOCCO3N+VilltEJ7/ztezxrTznqb + zYjgAh7OPD6bNUVr3ervHGtu6SziMWVcOKU/KWBqFk5wnqPNVbS5/dSHGYJjoI4dDEFBFyx0a1Dw + DtnP4Zg9mF38hmZvvkM3ry5RbtHVH2+vL369enP5sHtepBnUkNHihhELCeEerZke3vKCrl/8eP3P + i3c//d4Z0VqirZrm2WELFBFCKIE+nY2sE5Dd54/QF4/QY5tPu2+7qtRFCVuQ145aOMwKwxo4G3B3 + 71dSuO1o9vrl7Ptz+O1obx5THA2boBYtDmEjg5A4aCugjqJUaKszdrgyJq/MUCUD7b+2QkCJAlc8 + W9IMa7TXKGC/gusHPF39+fO7H151imrCpjVEuGcCiIoD/4beM+7nr+riM13oA53p0rlaHF5qlMF3 + ErwXMREBdr9u4MBpOYay0Ozi9fu/Lm7O//ZBdVkMps0ZrHpnXy/0xqr5/DqFQ1tUWTkYAgVlbzkI + z87+BQAA//8DAG/JjM+bCQAA + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '1101' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:51:14 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_LM610ARtyNAW03POEO6H1w=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:51:14 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828587397343113; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:51:14 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - 226a4ca2ac6b0c0c9e887ed5f8454d86 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '15' + x-rate-limit-remaining: + - '14' + x-rate-limit-reset: + - '1618286773' + x-response-time: + - '86' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_get_users_mentions.yaml b/cassettes/test_get_users_mentions.yaml new file mode 100644 index 0000000..c6d4930 --- /dev/null +++ b/cassettes/test_get_users_mentions.yaml @@ -0,0 +1,77 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/users/783214/mentions + response: + body: + string: !!binary | + H4sIAAAAAAAAAHxUzW7jNhB+lYEKFD24jmTJkZRe7G6KzXZ340Xs7Q+awhiJtMSYIgWSsiMHAfay + l1562VPR9lSgZ6OX3psncR+gr9Bxsq2NJFhBEEkN55vvmxnyymPo0Dv67soTzDvygjAJkiAKe1Ea + hWkUHIZ9r+M5funIOJgyLmu90lMYTJbCOW7gxcvhaDQCMsDWIjk8o4XlZsFBODhvjpPwC/oexwGU + SB4WCq0U3i686869uEHYj2jWP/TDvbi2FAucNxUa348jHwZPXo6OuSwFDIZYDZFV4hUa19LSLIRi + z/mFEUuUO5qDp1oXRO79+EwxgUBzBlo9pNFLEqIQRP20F+3RmHw7On364vVXn/uTHXKNn25+evfP + nz+CKhAaiuF0+Qiif9g/jPykn/j7wqxtcqMt3+EVgjJX0asNh1mjVEupKhHcknNn4ePCfXb0yZ2V + sqydVkI9Fm5LPu4F6X79VuRQclZQuLOGtSe44Mo6LtQuvCs5bN78bHPBlRMzkUNt9AXPndDKbt78 + QmSIX8a5glxXteSOyxb0ghuHc/qZtUCORtdtB1CxWzwpKuHwFgH0DEoqpKJdhVCcG6GKLu0SFuhd + UldQhLomXkC0UEpQTS45GsqJdEwvlSXgukZDYWTbfSg99pMw7vf7PX+/dk+0mgnGVc6PG+cQBuPX + 45Ph6eTL4elel7yfjJu61sbBpEQ1h1Y3YDVUTV5SaxOTvab2u/Ch52u08Jw0GUFYhlPLU7UKGI/P + HuMdhUmahlS2He+/3/52rs7Vf3ibX/+AzbsfYMzLJmuo4RQxuh3mPBMXOKdZhqb5X0kHxtgifKQY + aeCSDhFQbhtJuZ6jwflW9ZnYWoeSUU5nSBNbIqPsU30o6dthpk2FVtyhl0sEwlG0QwAylFjerakm + mrVA90kDhm6CWmLLTRe2AkjHQ8X9NI1JdxrEe2fihFvMbtbVzRoUhxVuewX/+h2NvVmrm/UKHJbV + NnQA7c1agpZEnuGuiKVztT06OHDdXB8MQ/Xqm1O1kHPv+vuOV/HtZXflkRO3bvoBNoov7++4dyka + bhvpprluFPFOti6Xbuo0nQLyiYPIZyJjSi/TPM7cMlxGrFdkCS8uq5jJMlv1qihOexfZBXG7/hcA + AP//AwB+P2WmiQUAAA== + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '868' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:39:55 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_heQcMZElZgg1GiD3RwMeeA=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:39:55 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828519489792657; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:39:55 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - f85ad90534a67e7168bc1457504d813f + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '450' + x-rate-limit-remaining: + - '449' + x-rate-limit-reset: + - '1618286094' + x-response-time: + - '140' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_get_users_tweets.yaml b/cassettes/test_get_users_tweets.yaml new file mode 100644 index 0000000..cc76550 --- /dev/null +++ b/cassettes/test_get_users_tweets.yaml @@ -0,0 +1,71 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/users/783214/tweets + response: + body: + string: !!binary | + H4sIAAAAAAAAAHyTzW7cIBSFX+WKTTazwGADnk2rVl1UbTZpdlVlYcPM4B+IAMfjjObdiydRa8VV + N5YNPt+5h3u5ICWjRPufF2QU2qOMCkwxywUrGeGCECzQDkV9jmnz4REOzkM0Xqsd9KbTt+9n7efX + RXTd/eHwMi95STKM88TjrPzL+aiMdYO0VQuTvvMa4knP77VFUdCMllgUlNCV9t54aZX8JEOQRwMy + yWc3QhjfOG88cFZ/2DBzlmNCOMFFlq+Yg+y09BFMvAtQy2AaGGQ8gdey7zeV5aJgjAiOU2Frim37 + avAJApMMIOFkbNxoM1ywxT0v+PpErElOoZ4a1zsfbomUUfYuQtBLHhOWUHaDwwUuyywjmAq+wj2k + wj+7YIZ00HB0sg/vlZTlGWOipCUX6xDtoqmCHZuuMhaeejkbe4ST9ApiYulNJJKmJI1Lnt7JmhSi + Mbab/ajhXs61htSU71+/ffmxpPPwOGkdw7LYjiGCcjoscW9TdXukvMPGi2OcvDgvKCMrr2fTK2lf + tD2m4hf+MgWT7hs3vM7oMhEHn46y9jLFmpzv3Jii/NqhQS8X4IJcr3SI1X/crJ5Wf/zrongdxj5W + jRtT6/cZXjTnWEXXpd7tEc9yrEytrJvKhtdxohOd1fjiDjwK+STOyh5aylrMppah6/U3AAAA//8D + AB3BvbeeAwAA + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '522' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:41:23 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_bo444/e9hn+uN/Yjvp/n1w=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:41:23 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828528362648741; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:41:23 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - 6d6c9476af9fa3c647a21476e10941fe + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '1500' + x-rate-limit-remaining: + - '1499' + x-rate-limit-reset: + - '1618286183' + x-response-time: + - '71' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_hide_and_unhide_reply.yaml b/cassettes/test_hide_and_unhide_reply.yaml new file mode 100644 index 0000000..59c3c93 --- /dev/null +++ b/cassettes/test_hide_and_unhide_reply.yaml @@ -0,0 +1,131 @@ +interactions: +- request: + body: '{"hidden": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '16' + Content-Type: + - application/json + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: PUT + uri: https://api.twitter.com/2/tweets/1344794616005066752/hidden + response: + body: + string: !!binary | + H4sIAAAAAAAAAKpWSkksSVSyqlbKyExJSc1TsiopKk2trQUAAAD//wMAM35dFBgAAAA= + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '50' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:34:08 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_GFbL3qKdfnGNOe10xvUKog=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:34:08 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828484873628002; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:34:08 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read-write-directmessages + x-connection-hash: + - 13ca5608ca982b747aafb1016d9c66a9 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '50' + x-rate-limit-remaining: + - '45' + x-rate-limit-reset: + - '1618285574' + x-response-time: + - '43' + x-tsa-request-body-time: + - '4' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +- request: + body: '{"hidden": false}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '17' + Content-Type: + - application/json + Cookie: + - guest_id=v1%3A161828484873628002; personalization_id="v1_GFbL3qKdfnGNOe10xvUKog==" + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: PUT + uri: https://api.twitter.com/2/tweets/1344794616005066752/hidden + response: + body: + string: !!binary | + H4sIAAAAAAAAAKpWSkksSVSyqlbKyExJSc1TskpLzClOra0FAAAA//8DAM4sxjwZAAAA + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '51' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:34:08 GMT + server: + - tsa_b + strict-transport-security: + - max-age=631138519 + x-access-level: + - read-write-directmessages + x-connection-hash: + - 13ca5608ca982b747aafb1016d9c66a9 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '50' + x-rate-limit-remaining: + - '44' + x-rate-limit-reset: + - '1618285574' + x-response-time: + - '66' + x-tsa-request-body-time: + - '0' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/cassettes/test_search_recent_tweets.yaml b/cassettes/test_search_recent_tweets.yaml new file mode 100644 index 0000000..b33abbb --- /dev/null +++ b/cassettes/test_search_recent_tweets.yaml @@ -0,0 +1,79 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - Python/3.9.1 Requests/2.25.1 Tweepy/3.10.0 + method: GET + uri: https://api.twitter.com/2/tweets/search/recent?query=Tweepy + response: + body: + string: !!binary | + H4sIAAAAAAAAAORW72vbRhj+V97JH/zFSySd7JP8aWEra+joyuoORleMbJ1tObLOPZ2buiEQSaWs + ENhKWUPaQtdmW9alS9v9bLzkn9lVXvJf7GQnxD9C2RijhYGQxN17z733PO+jV0uKY3NbKV5cUlxH + KSoaMjVT0xFCGCOMkGlpSk7h5CqXkx+V4J12lzeoX3aDhrtAGS1Cf+2b/v0nItwW8XURfS3iXRF/ + NrieiPgnEd8U8bqIduSIporw6cVs5uWLFy97K/sbewe9ngi/FNFtEd4Q4WP5kuyGyd7tg40HItwR + obxfF+GmCNezOciKaAi4IuKvku0HyY31ZPXOYCKWGJsi/l5Ev4n4UTr0voh+HyTzhcwnHTj78fx7 + 83PpW0ZEv4joqUzvz/W9/sNYhKuj+6Uh/bvbIropwjV5qoN7t/Z//O4MswM6mHq2ltzfTE8b3htE + /7HyrbKcG2dPV01Jna4ahqkfs/c/JwqyybNbyc7Pg9UPh+k8EvGWiLbk1lp+//Hz7KXhIcRKlBnW + GWT4IiHt7iTFKjYKuq4hpBpohOLzxHdcvw6tLtRcFnBIV3O44tpQGuC8NQGk4rTQdUM3VdMYATpN + PI8erplcktfVvKpbpoFVQ/sH8pY+PPdfCTul4glKHws7qcMrVJyW6GRpM8mdrf3VX5NeiiGZOFIS + MucOdTyZS+kQw8C4YKhYNcc/NIxWCOO0XLEDTn1ShBJ17C5oCObaDHRV13Lg+nDWblPPzQFvEAg6 + Piy6ngfMDQjYHNRCUc8XjTy8e+p8CWzfGQ8LZG3IKM0qGmrRMAdRM1BquMFh4bjBtL1lztLgWFaO + ivMjJfNa0gO7w+nbdeITZnPiQKULNhxSXqEc5qHKyGCmE6TGGKqQghBo0A4LwHGDtmd3ZUSDMAJV + 2iJQY7QFDc7bQXF2ls9U6WyjVKo59Qtzp7WZT/1jUYcm9YjNfIk+ThS2sHSVhVWkIaxbb3wXmfLQ + pE2ODXSCu/6Nh6ZqDFsFC+lp+zVMlEdvUgt5fSwdtZwfNpLdz/vPe8n23b/bL7CVt9IvTd7Ammwc + I55Ng08xRllx6KsWkSgOOJQE4Ev/tAmrUdaCtl13fZu7cocxXzR9p/nJnIub2tHOkAmIz92WvNm+ + 7XUDiTqY4vLZ7Mg0CZPIpELpwjiW06x9gFnbu3BGWb6UU2Qq8r9sSfHJIgl4+RV/Z9RzxiKmj8tI + 0PF4uUo7vjy2puYk6lVe5nSB+HJRRS9cMa2qZl27XDcpqtGAM3wZ1SvIIBWCPMQdrVsP2ga7tugo + y8t/AQAA//8DAGBs9QU1CgAA + headers: + cache-control: + - no-cache, no-store, max-age=0 + content-disposition: + - attachment; filename=json.json + content-encoding: + - gzip + content-length: + - '987' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Apr 2021 03:39:55 GMT + server: + - tsa_b + set-cookie: + - personalization_id="v1_ZuOQMrjuAi1vFAu/ANL3uw=="; Max-Age=63072000; Expires=Thu, + 13 Apr 2023 03:39:55 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A161828519538371875; Max-Age=63072000; Expires=Thu, 13 Apr 2023 + 03:39:55 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + strict-transport-security: + - max-age=631138519 + x-access-level: + - read + x-connection-hash: + - 49fc3db116d587525eee6ee8b5068c29 + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-rate-limit-limit: + - '450' + x-rate-limit-remaining: + - '449' + x-rate-limit-reset: + - '1618286095' + x-response-time: + - '121' + x-xss-protection: + - '0' + status: + code: 200 + message: OK +version: 1 diff --git a/docs/running_tests.rst b/docs/running_tests.rst index 3131751..4dd397f 100644 --- a/docs/running_tests.rst +++ b/docs/running_tests.rst @@ -19,6 +19,7 @@ These steps outline how to run tests for Tweepy: To record new cassettes, the following environment variables can be used: ``TWITTER_USERNAME`` +``BEARER_TOKEN`` ``CONSUMER_KEY`` ``CONSUMER_SECRET`` ``ACCESS_KEY`` diff --git a/setup.cfg b/setup.cfg index 5a1e4f1..4ca9624 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,6 @@ universal = 1 [nosetests] -tests = tests.test_api,tests.test_cursors,tests.test_resultset,tests.test_utils +tests = tests.test_api,tests.test_client,tests.test_cursors,tests.test_resultset,tests.test_utils verbosity = 2 with-coverage = 1 diff --git a/tests/config.py b/tests/config.py index 0fcea92..6f65c40 100644 --- a/tests/config.py +++ b/tests/config.py @@ -7,11 +7,13 @@ from tweepy.api import API from tweepy.auth import OAuthHandler +user_id = os.environ.get('TWITTER_USER_ID', '1072250532645998596') username = os.environ.get('TWITTER_USERNAME', 'TweepyDev') -oauth_consumer_key = os.environ.get('CONSUMER_KEY', '') -oauth_consumer_secret = os.environ.get('CONSUMER_SECRET', '') -oauth_token = os.environ.get('ACCESS_KEY', '') -oauth_token_secret = os.environ.get('ACCESS_SECRET', '') +bearer_token = os.environ.get('BEARER_TOKEN', '') +consumer_key = os.environ.get('CONSUMER_KEY', '') +consumer_secret = os.environ.get('CONSUMER_SECRET', '') +access_token = os.environ.get('ACCESS_KEY', '') +access_token_secret = os.environ.get('ACCESS_SECRET', '') use_replay = os.environ.get('USE_REPLAY', True) @@ -33,6 +35,6 @@ class TweepyTestCase(unittest.TestCase): def create_auth(): - auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret) - auth.set_access_token(oauth_token, oauth_token_secret) + auth = OAuthHandler(consumer_key, consumer_secret) + auth.set_access_token(access_token, access_token_secret) return auth diff --git a/tests/test_client.py b/tests/test_client.py new file mode 100644 index 0000000..e47502c --- /dev/null +++ b/tests/test_client.py @@ -0,0 +1,72 @@ +import unittest + +from .config import ( + access_token, access_token_secret, bearer_token, consumer_key, + consumer_secret, tape, user_id +) +import tweepy + +class TweepyTestCase(unittest.TestCase): + + def setUp(self): + self.client = tweepy.Client( + bearer_token, consumer_key, consumer_secret, + access_token or user_id, access_token_secret + ) + + @tape.use_cassette("test_hide_and_unhide_reply.yaml", serializer='yaml') + def test_hide_and_unhide_reply(self): + reply_id = 1344794616005066752 # Test Tweet for reply hide/unhide + self.assertTrue(self.client.hide_reply(reply_id)) + self.assertFalse(self.client.unhide_reply(reply_id)) + + # TODO: test_search_all_tweets with access to Academic Research product track + + @tape.use_cassette("test_search_recent_tweets.yaml", serializer='yaml') + def test_search_recent_tweets(self): + self.client.search_recent_tweets("Tweepy") + + @tape.use_cassette("test_get_users_mentions.yaml", serializer='yaml') + def test_get_users_mentions(self): + user_id = 783214 # User ID for @Twitter + self.client.get_users_mentions(user_id) + + @tape.use_cassette("test_get_users_tweets.yaml", serializer='yaml') + def test_get_users_tweets(self): + user_id = 783214 # User ID for @Twitter + self.client.get_users_tweets(user_id) + + @tape.use_cassette("test_get_tweet.yaml", serializer='yaml') + def test_get_tweet(self): + tweet_id = 1293593516040269825 # @TwitterDev Tweet announcing API v2 + self.client.get_tweet(tweet_id) + + @tape.use_cassette("test_get_tweets.yaml", serializer='yaml') + def test_get_tweets(self): + tweet_ids = [1293593516040269825, 1293595870563381249] + # @TwitterDev and @TwitterAPI Tweets announcing API v2 + self.client.get_tweets(tweet_ids) + + @tape.use_cassette("test_follow_and_unfollow.yaml", serializer='yaml') + def test_follow_and_unfollow(self): + user_id = 783214 # User ID for @Twitter + self.client.unfollow(user_id) + self.client.follow(user_id) + + @tape.use_cassette("test_get_users_followers.yaml", serializer='yaml') + def test_get_users_followers(self): + user_id = 783214 # User ID for @Twitter + self.client.get_users_followers(user_id) + + @tape.use_cassette("test_get_users_following.yaml", serializer='yaml') + def test_get_users_following(self): + user_id = 783214 # User ID for @Twitter + self.client.get_users_following(user_id) + + @tape.use_cassette("test_get_user.yaml", serializer='yaml') + def test_get_user(self): + self.client.get_user(username="Twitter") + + @tape.use_cassette("test_get_users.yaml", serializer='yaml') + def test_get_users(self): + self.client.get_users(usernames=["Twitter", "TwitterDev"]) -- 2.25.1