From ac7196c443db8453ccb6c3c2407c9e844ea4cbae Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Sun, 28 Apr 2019 13:58:18 +0200 Subject: Add conversation read marking + tests/docs --- docs/index.rst | 16 ++-- mastodon/Mastodon.py | 15 ++++ tests/cassettes/test_conversations.yaml | 131 +++++++++++++++++++++++++++----- tests/test_timeline.py | 6 +- 4 files changed, 142 insertions(+), 26 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 9bbd6f7..48fb0c1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,7 +3,7 @@ Mastodon.py .. py:module:: mastodon .. py:class: Mastodon -Register your app! This only needs to be done once. Uncomment the code and substitute in your information. +Register your app! This only needs to be done once. Uncomment the code and substitute in your information: .. code-block:: python @@ -17,7 +17,7 @@ Register your app! This only needs to be done once. Uncomment the code and subst ) ''' -Then login. This can be done every time, or use persisted. +Then login. This can be done every time, or you can use the persisted information: .. code-block:: python @@ -33,7 +33,7 @@ Then login. This can be done every time, or use persisted. to_file = 'pytooter_usercred.secret' ) -To post, create an actual API instance. +To post, create an actual API instance: .. code-block:: python @@ -790,7 +790,7 @@ These functions allow you to view information about lists. Reading data: Follows --------------------- -.. automethod:: Mastodon.follows +.. automethod:: Mastodon.followshttps://docs.joinmastodon.org/api/rest Reading data: Favourites ------------------------ @@ -868,6 +868,12 @@ These functions allow you to clear all or some notifications. .. automethod:: Mastodon.notifications_clear .. automethod:: Mastodon.notifications_dismiss +Writing data: Conversations +--------------------------- +This function allows you to mark conversations read. + +.. automethod:: Mastodon.conversations_read + Writing data: Accounts ---------------------- These functions allow you to interact with other accounts: To (un)follow and @@ -1023,4 +1029,4 @@ about who helped with which particular feature or fix in the changelog. .. _Mastodon: https://github.com/tootsuite/mastodon .. _Mastodon flagship instance: http://mastodon.social/ -.. _Mastodon api docs: https://github.com/tootsuite/documentation/ +.. _Official Mastodon api docs: https://docs.joinmastodon.org/api/rest diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 6897bc6..f5bf4ac 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -1495,6 +1495,21 @@ class Mastodon: params = self.__generate_params(locals()) self.__api_request('POST', '/api/v1/notifications/dismiss', params) + + ### + # Writing data: Conversations + ### + def conversations_read(self, id): + """ + Marks a single conversation as read. + + WARNING: This method is currently not documented in the official API and + might therefore be unstable. + """ + id = self.__unpack_id(id) + url = '/api/v1/conversations/{0}/read'.format(str(id)) + return self.__api_request('POST', url) + ### # Writing data: Accounts ### diff --git a/tests/cassettes/test_conversations.yaml b/tests/cassettes/test_conversations.yaml index f4f0b15..105eb98 100644 --- a/tests/cassettes/test_conversations.yaml +++ b/tests/cassettes/test_conversations.yaml @@ -14,7 +14,7 @@ interactions: headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"22befe12cde5f76de801140c68ff24d7"] + ETag: [W/"589b7fc34678284181e4970961b98b8f"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -22,8 +22,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [f61f2b83-2a73-4874-a883-70240d83b453] - X-Runtime: ['0.021142'] + X-Request-Id: [9f267b49-db2e-43ae-821d-f8e06bd6ef6e] + X-Runtime: ['0.021003'] X-XSS-Protection: [1; mode=block] content-length: ['653'] status: {code: 200, message: OK} @@ -40,15 +40,15 @@ interactions: method: POST uri: http://localhost:3000/api/v1/statuses response: - body: {string: '{"id":"102003581864478788","created_at":"2019-04-28T11:32:19.297Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003581864478788","content":"\u003cp\u003e\u003cspan + body: {string: '{"id":"102003683512723982","created_at":"2019-04-28T11:58:10.333Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003683512723982","content":"\u003cp\u003e\u003cspan class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e - ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003581864478788","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003683512723982","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"dc7ff9b9023358ffdcb2a1507e9e77e6"] + ETag: [W/"2664c447c45638697eacdaa9cb643dae"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -56,8 +56,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [de40a9dc-97f0-4805-a24a-8378f8f37de9] - X-Runtime: ['0.160974'] + X-Request-Id: [22e1eea7-613e-4a9f-8785-4cca0660a929] + X-Runtime: ['0.167697'] X-XSS-Protection: [1; mode=block] content-length: ['1475'] status: {code: 200, message: OK} @@ -72,11 +72,102 @@ interactions: method: GET uri: http://localhost:3000/api/v1/conversations/ response: - body: {string: '[{"id":"24","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003581864478788","created_at":"2019-04-28T11:32:19.297Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003581864478788","content":"\u003cp\u003e\u003cspan + body: {string: '[{"id":"30","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003683512723982","created_at":"2019-04-28T11:58:10.333Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003683512723982","content":"\u003cp\u003e\u003cspan class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e - ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003581864478788","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py - test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"22","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003580476156514","created_at":"2019-04-28T11:31:58.113Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003580476156514","content":"\u003cp\u003e\u003cspan + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003683512723982","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"26","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003680467810506","created_at":"2019-04-28T11:57:23.865Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003680467810506","content":"\u003cp\u003e\u003cspan + class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url + mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003680467810506","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"22","unread":false,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003580476156514","created_at":"2019-04-28T11:31:58.113Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003580476156514","content":"\u003cp\u003e\u003cspan + class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url + mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003580476156514","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"18","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003573042670077","created_at":"2019-04-28T11:30:04.687Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003573042670077","content":"\u003cp\u003e\u003cspan + class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url + mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003573042670077","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"14","unread":false,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003565381731428","created_at":"2019-04-28T11:28:07.791Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003565381731428","content":"\u003cp\u003e\u003cspan + class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url + mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003565381731428","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"4","unread":false,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003533707396851","created_at":"2019-04-28T11:20:04.478Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003533707396851","content":"\u003cp\u003e\u003cspan + class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url + mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e + test\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003533707396851","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"08eb290a1d5b5c9c9f0b6198cb1eba3b"] + Link: ['; + rel="prev"'] + Referrer-Policy: [strict-origin-when-cross-origin] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Download-Options: [noopen] + X-Frame-Options: [SAMEORIGIN] + X-Permitted-Cross-Domain-Policies: [none] + X-Request-Id: [bdcc2508-446e-4366-8c19-f24ba8e165cf] + X-Runtime: ['0.184464'] + X-XSS-Protection: [1; mode=block] + content-length: ['12579'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/conversations/30/read + response: + body: {string: '{"id":"30","unread":false,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003683512723982","created_at":"2019-04-28T11:58:10.333Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003683512723982","content":"\u003cp\u003e\u003cspan + class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url + mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003683512723982","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"13f3289f4d462887396bc58d863578c2"] + Referrer-Policy: [strict-origin-when-cross-origin] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Download-Options: [noopen] + X-Frame-Options: [SAMEORIGIN] + X-Permitted-Cross-Domain-Policies: [none] + X-Request-Id: [60024dfb-b47d-44cd-bf4d-b8ecd77b7848] + X-Runtime: ['0.055070'] + X-XSS-Protection: [1; mode=block] + content-length: ['2097'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] + Connection: [keep-alive] + User-Agent: [python-requests/2.18.4] + method: GET + uri: http://localhost:3000/api/v1/conversations/ + response: + body: {string: '[{"id":"30","unread":false,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003683512723982","created_at":"2019-04-28T11:58:10.333Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003683512723982","content":"\u003cp\u003e\u003cspan + class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url + mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003683512723982","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"26","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003680467810506","created_at":"2019-04-28T11:57:23.865Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003680467810506","content":"\u003cp\u003e\u003cspan + class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url + mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e + ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003680467810506","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"22","unread":false,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003580476156514","created_at":"2019-04-28T11:31:58.113Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003580476156514","content":"\u003cp\u003e\u003cspan class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003580476156514","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py @@ -96,8 +187,8 @@ interactions: headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"79b5a64acc37c8440422aa5612672686"] - Link: ['; + ETag: [W/"72bd0df2c4806b9f75ad414206794e61"] + Link: ['; rel="prev"'] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] @@ -106,10 +197,10 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [b9d855cb-8dcd-4498-ae9c-57a9891c1d19] - X-Runtime: ['0.175062'] + X-Request-Id: [f8157f06-87e0-496d-99f2-486957c07ac3] + X-Runtime: ['0.228299'] X-XSS-Protection: [1; mode=block] - content-length: ['10481'] + content-length: ['12580'] status: {code: 200, message: OK} - request: body: null @@ -121,13 +212,13 @@ interactions: Content-Length: ['0'] User-Agent: [python-requests/2.18.4] method: DELETE - uri: http://localhost:3000/api/v1/statuses/102003581864478788 + uri: http://localhost:3000/api/v1/statuses/102003683512723982 response: body: {string: '{}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"0f55e9de51b2e35f7a3eecdfab3e2571"] + ETag: [W/"35127b8d5250775810c927176b395efa"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -135,8 +226,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [e9e9ed92-a1c4-4bc7-ab9e-5e1a2df23660] - X-Runtime: ['0.024581'] + X-Request-Id: [dae42ec5-5ddc-401a-a9d1-b535e5d20a2e] + X-Runtime: ['0.037362'] X-XSS-Protection: [1; mode=block] content-length: ['2'] status: {code: 200, message: OK} diff --git a/tests/test_timeline.py b/tests/test_timeline.py index 3a75029..93ac8de 100644 --- a/tests/test_timeline.py +++ b/tests/test_timeline.py @@ -50,8 +50,12 @@ def test_conversations(api, api2): status = api.status_post("@admin ilu bby ;3", visibility="direct") time.sleep(2) conversations = api2.conversations() + api2.conversations_read(conversations[0]) + time.sleep(2) + conversations2 = api2.conversations() api.status_delete(status) assert conversations assert status.id in map(lambda x: x.last_status.id, conversations) assert account.id in map(lambda x: x.accounts[0].id, conversations) - + assert conversations[0].unread == True + assert conversations2[0].unread == False -- cgit v1.2.3