diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 5ba33d4..1d23fad 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -2475,7 +2475,7 @@ class Mastodon: if connection.status_code != 200: raise MastodonNetworkError("Could not connect to streaming server: %s" % connection.reason) return connection - connection = connect_func() + connection = None # Async stream handler class __stream_handle(): @@ -2506,18 +2506,19 @@ class Mastodon: # Run until closed or until error if not autoreconnecting while self.running: - with closing(self.connection) as r: - try: - listener.handle_stream(r) - except (AttributeError, MastodonMalformedEventError, MastodonNetworkError) as e: - if not (self.closed or self.reconnect_async): - raise e - else: - if self.closed: - self.running = False + if not self.connection is None: + with closing(self.connection) as r: + try: + listener.handle_stream(r) + except (AttributeError, MastodonMalformedEventError, MastodonNetworkError) as e: + if not (self.closed or self.reconnect_async): + raise e + else: + if self.closed: + self.running = False # Reconnect loop. Try immediately once, then with delays on error. - if self.reconnect_async and not self.closed: + if (self.reconnect_async and not self.closed) or self.connection is None: self.reconnecting = True connect_success = False while not connect_success: @@ -2527,6 +2528,8 @@ class Mastodon: if self.connection.status_code != 200: time.sleep(self.reconnect_async_wait_sec) connect_success = False + exception = MastodonNetworkError("Could not connect to server.") + listener.on_abort(exception) except: time.sleep(self.reconnect_async_wait_sec) connect_success = False @@ -2543,6 +2546,7 @@ class Mastodon: return handle else: # Blocking, never returns (can only leave via exception) + connection = connect_func() with closing(connection) as r: listener.handle_stream(r) diff --git a/tests/cassettes/test_stream_user.yaml b/tests/cassettes/test_stream_user.yaml index a94f406..f0a1ae4 100644 --- a/tests/cassettes/test_stream_user.yaml +++ b/tests/cassettes/test_stream_user.yaml @@ -10,11 +10,11 @@ interactions: method: GET uri: http://localhost:3000/api/v1/accounts/verify_credentials response: - body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T17:58:11.427Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","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,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'} + body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","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":8,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"1eeedcf7d78b94ca6724689f4261e8be"] + ETag: [W/"cd2127b055679523c42093d9fa35eaf9"] 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: [5a5014a0-a99f-47b9-bac8-d6da55fc2b90] - X-Runtime: ['0.021655'] + X-Request-Id: [d33ae198-a4ca-4207-afb4-036e11d9033b] + X-Runtime: ['0.190787'] X-XSS-Protection: [1; mode=block] content-length: ['609'] status: {code: 200, message: OK} @@ -43,7 +43,7 @@ interactions: headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"11a1598090f5bf88f40c31bd3606dbef"] + ETag: [W/"c69d2321c40813c2e91746f6df8c685b"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -51,8 +51,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [e82a8459-b71e-4ad6-85f3-7a3ff66e12d5] - X-Runtime: ['0.023404'] + X-Request-Id: [559452ea-a4ca-49ce-a41c-9789a4e175d6] + X-Runtime: ['0.027095'] X-XSS-Protection: [1; mode=block] content-length: ['211'] status: {code: 200, message: OK} @@ -67,12 +67,12 @@ interactions: method: GET uri: http://localhost:3000/api/v1/instance/ response: - body: {string: '{"uri":"localhost","title":"Mastodon","description":"","email":"","version":"2.8.0","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":66,"domain_count":0},"thumbnail":"http://localhost/packs/media/images/preview-9a17d32fc48369e8ccd910a75260e67d.jpg","languages":["en"],"registrations":true,"contact_account":null}'} + body: {string: '{"uri":"localhost","title":"Mastodon","description":"","email":"","version":"2.8.0","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":10,"domain_count":0},"thumbnail":"http://localhost/packs/media/images/preview-9a17d32fc48369e8ccd910a75260e67d.jpg","languages":["en"],"registrations":true,"contact_account":null}'} headers: Cache-Control: ['max-age=300, public'] Content-Type: [application/json; charset=utf-8] - Date: ['Sat, 27 Apr 2019 18:18:46 GMT'] - ETag: [W/"d335ec7c575ba1754000860090deaab6"] + Date: ['Sat, 27 Apr 2019 23:51:08 GMT'] + ETag: [W/"1853e19f93744ec050047787c0defeb4"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -80,8 +80,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [de676fbf-ea1f-48ce-9646-f86d92162a8b] - X-Runtime: ['0.046948'] + X-Request-Id: [15378378-5d7a-4d03-aef0-2da0d7523ab3] + X-Runtime: ['0.038039'] X-XSS-Protection: [1; mode=block] content-length: ['349'] status: {code: 200, message: OK} @@ -98,15 +98,13 @@ interactions: method: POST uri: http://localhost:3000/api/v1/statuses response: - body: {string: '{"id":"101999518125980927","created_at":"2019-04-27T18:18:51.589Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/mastodonpy_test/statuses/101999518125980927","content":"\u003cp\u003eonly - real cars respond.\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/101999518125980927","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py - test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John - Lennon","locked":true,"bot":false,"created_at":"2019-04-27T20:03:12.393Z","note":"\u003cp\u003eI - walk funny\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","avatar_static":"http://localhost/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","header":"http://localhost/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","header_static":"http://localhost/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","followers_count":0,"following_count":0,"statuses_count":63,"emojis":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'} + body: {string: '{"id":"102000825046689277","created_at":"2019-04-27T23:51:13.758Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/mastodonpy_test/statuses/102000825046689277","content":"\u003cp\u003eonly + real cars respond.\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102000825046689277","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":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":3,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"389a02cefbfab01ed906d5eced810cfb"] + ETag: [W/"6a5a7e8c76cf1f6e542c7fa3d0b324e6"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -114,10 +112,10 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [e8077894-efd5-4970-91eb-902d0af25a86] - X-Runtime: ['0.410379'] + X-Request-Id: [f07f61fc-8265-4d61-8c98-84e0388f31c0] + X-Runtime: ['0.541242'] X-XSS-Protection: [1; mode=block] - content-length: ['1616'] + content-length: ['1253'] status: {code: 200, message: OK} - request: body: status=%40mastodonpy_test+beep+beep+I%27m+a+jeep @@ -132,15 +130,15 @@ interactions: method: POST uri: http://localhost:3000/api/v1/statuses response: - body: {string: '{"id":"101999518153289143","created_at":"2019-04-27T18:18:52.027Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/101999518153289143","content":"\u003cp\u003e\u003cspan + body: {string: '{"id":"102000825079136326","created_at":"2019-04-27T23:51:14.093Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102000825079136326","content":"\u003cp\u003e\u003cspan class=\"h-card\"\u003e\u003ca href=\"http://localhost/@mastodonpy_test\" class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e - beep beep I\u0026apos;m a jeep\u003c/p\u003e","url":"http://localhost/@admin/101999518153289143","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py - test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T17:58:11.427Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","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":5,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}'} + beep beep I\u0026apos;m a jeep\u003c/p\u003e","url":"http://localhost/@admin/102000825079136326","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","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":9,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"c83781decbfc6a65c1e323598aab069a"] + ETag: [W/"2ccbe7c603db538a9b9d94ff8174016d"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -148,8 +146,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [56d08555-33d7-40f1-8f3c-aa5e737a2efe] - X-Runtime: ['0.461534'] + X-Request-Id: [13c205c2-e5bc-4469-b6a0-a7dc18dd5f11] + X-Runtime: ['0.213550'] X-XSS-Protection: [1; mode=block] content-length: ['1511'] status: {code: 200, message: OK} @@ -166,13 +164,13 @@ interactions: method: POST uri: http://localhost:3000/api/v1/statuses response: - body: {string: '{"id":"101999518193602263","created_at":"2019-04-27T18:18:52.634Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/101999518193602263","content":"\u003cp\u003eon - the internet, nobody knows you\u0026apos;re a plane\u003c/p\u003e","url":"http://localhost/@admin/101999518193602263","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py - test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T17:58:11.427Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","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":6,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'} + body: {string: '{"id":"102000825095837749","created_at":"2019-04-27T23:51:14.349Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102000825095837749","content":"\u003cp\u003eon + the internet, nobody knows you\u0026apos;re a plane\u003c/p\u003e","url":"http://localhost/@admin/102000825095837749","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","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":10,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"f56ee957e06ac66528b5a235a0c83d4c"] + ETag: [W/"c2ab6b89316efb69005c230c72accb6b"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -180,10 +178,10 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [eeb9bca6-952a-4e5f-b124-68eb57cbd9c2] - X-Runtime: ['0.410981'] + X-Request-Id: [48b902b9-9cb6-422d-a3f1-ea014a8cd6e7] + X-Runtime: ['0.165465'] X-XSS-Protection: [1; mode=block] - content-length: ['1220'] + content-length: ['1221'] status: {code: 200, message: OK} - request: body: null @@ -195,13 +193,13 @@ interactions: Content-Length: ['0'] User-Agent: [python-requests/2.18.4] method: DELETE - uri: http://localhost:3000/api/v1/statuses/101999518125980927 + uri: http://localhost:3000/api/v1/statuses/102000825046689277 response: body: {string: '{}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"0e17500f6fd394ef25f979c06f837df5"] + ETag: [W/"68dc9d53058fab55b922570e8d9416d8"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -209,8 +207,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [588349bf-94fa-4ce7-8e2b-85b6c48cdca8] - X-Runtime: ['0.026396'] + X-Request-Id: [1c002f40-b79d-40a4-8e64-e8e81bbde4a3] + X-Runtime: ['0.062087'] X-XSS-Protection: [1; mode=block] content-length: ['2'] status: {code: 200, message: OK} @@ -227,24 +225,22 @@ interactions: response: body: {string: 'event: update - data: {"id":"101999518125980927","created_at":"2019-04-27T18:18:51.589Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/mastodonpy_test/statuses/101999518125980927","content":"
only - real cars respond.
","url":"http://localhost/@mastodonpy_test/101999518125980927","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py - test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John - Lennon","locked":true,"bot":false,"created_at":"2019-04-27T20:03:12.393Z","note":"I - walk funny
","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","avatar_static":"http://localhost/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","header":"http://localhost/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","header_static":"http://localhost/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","followers_count":0,"following_count":0,"statuses_count":63,"emojis":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null} + data: {"id":"102000825046689277","created_at":"2019-04-27T23:51:13.758Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/mastodonpy_test/statuses/102000825046689277","content":"only + real cars respond.
","url":"http://localhost/@mastodonpy_test/102000825046689277","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":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":"","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":3,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null} event: notification - data: {"id":"38","type":"mention","created_at":"2019-04-27T18:18:52.283Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T17:58:11.427Z","note":"","url":"http://localhost/@admin","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":5,"emojis":[],"fields":[]},"status":{"id":"101999518153289143","created_at":"2019-04-27T18:18:52.027Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/101999518153289143","content":"","url":"http://localhost/@admin","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":9,"emojis":[],"fields":[]},"status":{"id":"102000825079136326","created_at":"2019-04-27T23:51:14.093Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102000825079136326","content":"
@mastodonpy_test beep beep I'm a jeep
","url":"http://localhost/@admin/101999518153289143","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":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T17:58:11.427Z","note":"","url":"http://localhost/@admin","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":5,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}} + mention\">@mastodonpy_test beep beep I'm a jeep","url":"http://localhost/@admin/102000825079136326","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":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","note":"","url":"http://localhost/@admin","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":9,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}} event: delete - data: 101999518125980927 + data: 102000825046689277 :'} @@ -254,9 +250,9 @@ interactions: Access-Control-Allow-Origin: ['*'] Connection: [keep-alive] Content-Type: [text/event-stream] - Date: ['Sat, 27 Apr 2019 18:18:51 GMT'] + Date: ['Sat, 27 Apr 2019 23:51:14 GMT'] Transfer-Encoding: [chunked] X-Powered-By: [Express] - X-Request-Id: [8ac2ac89-1888-4733-97f6-22252010d097] + X-Request-Id: [b9afd71f-bd22-418a-82c9-b6b308aaf422] status: {code: 200, message: OK} version: 1 diff --git a/tests/cassettes/test_stream_user_local.yaml b/tests/cassettes/test_stream_user_local.yaml index 9d72a4d..22de8fb 100644 --- a/tests/cassettes/test_stream_user_local.yaml +++ b/tests/cassettes/test_stream_user_local.yaml @@ -10,11 +10,11 @@ interactions: method: GET uri: http://localhost:3000/api/v1/accounts/verify_credentials response: - body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T17:58:11.427Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","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":6,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'} + body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","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":10,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"183e1b0f0d58dd3b410dd700a2727161"] + ETag: [W/"897cda4d35dcffc1a0e9dd29fc71130f"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -22,10 +22,10 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [c7ad422b-3b8f-4a21-a661-0c1c0778966d] - X-Runtime: ['0.030147'] + X-Request-Id: [9c808452-96f3-4dee-b8b4-5159a9686307] + X-Runtime: ['0.024396'] X-XSS-Protection: [1; mode=block] - content-length: ['609'] + content-length: ['610'] status: {code: 200, message: OK} - request: body: null @@ -43,7 +43,7 @@ interactions: headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"41cf01fea278b3569d7c8d5a5c5782ec"] + ETag: [W/"2268b88a081c532f69d4e8f3f6cc1a41"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -51,8 +51,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [194e9c74-f1f7-489a-9cdc-dcc6cdb2872c] - X-Runtime: ['0.025540'] + X-Request-Id: [809c4964-6493-485a-8a47-5ffc3c0e6d5d] + X-Runtime: ['0.022342'] X-XSS-Protection: [1; mode=block] content-length: ['211'] status: {code: 200, message: OK} @@ -67,12 +67,12 @@ interactions: method: GET uri: http://localhost:3000/api/v1/instance/ response: - body: {string: '{"uri":"localhost","title":"Mastodon","description":"","email":"","version":"2.8.0","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":68,"domain_count":0},"thumbnail":"http://localhost/packs/media/images/preview-9a17d32fc48369e8ccd910a75260e67d.jpg","languages":["en"],"registrations":true,"contact_account":null}'} + body: {string: '{"uri":"localhost","title":"Mastodon","description":"","email":"","version":"2.8.0","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":12,"domain_count":0},"thumbnail":"http://localhost/packs/media/images/preview-9a17d32fc48369e8ccd910a75260e67d.jpg","languages":["en"],"registrations":true,"contact_account":null}'} headers: Cache-Control: ['max-age=300, public'] Content-Type: [application/json; charset=utf-8] - Date: ['Sat, 27 Apr 2019 18:19:24 GMT'] - ETag: [W/"ad3c648b6557460453c53744b0145a35"] + Date: ['Sat, 27 Apr 2019 23:51:28 GMT'] + ETag: [W/"23dbf13c779b1cc02bec5079773083f5"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -80,8 +80,8 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [6171dbda-326f-42e2-8e40-10b8d18bbe74] - X-Runtime: ['0.025239'] + X-Request-Id: [b3f91b98-37e1-4689-b1d5-ca0915bc72c6] + X-Runtime: ['0.023238'] X-XSS-Protection: [1; mode=block] content-length: ['349'] status: {code: 200, message: OK} @@ -98,15 +98,13 @@ interactions: method: POST uri: http://localhost:3000/api/v1/statuses response: - body: {string: '{"id":"101999520584397869","created_at":"2019-04-27T18:19:29.079Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/101999520584397869","content":"\u003cp\u003eit\u0026apos;s - cool guy\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/101999520584397869","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py - test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John - Lennon","locked":true,"bot":false,"created_at":"2019-04-27T20:03:12.393Z","note":"\u003cp\u003eI - walk funny\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","avatar_static":"http://localhost/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","header":"http://localhost/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","header_static":"http://localhost/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","followers_count":0,"following_count":0,"statuses_count":63,"emojis":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'} + body: {string: '{"id":"102000826367266958","created_at":"2019-04-27T23:51:33.747Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102000826367266958","content":"\u003cp\u003eit\u0026apos;s + cool guy\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102000826367266958","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":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":3,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'} headers: Cache-Control: ['max-age=0, private, must-revalidate'] Content-Type: [application/json; charset=utf-8] - ETag: [W/"773142da1c08dd0b884a6c52bdd50256"] + ETag: [W/"31fb33fa6323ac79ab4d8a1caf4d1c40"] Referrer-Policy: [strict-origin-when-cross-origin] Transfer-Encoding: [chunked] Vary: ['Accept-Encoding, Origin'] @@ -114,10 +112,10 @@ interactions: X-Download-Options: [noopen] X-Frame-Options: [SAMEORIGIN] X-Permitted-Cross-Domain-Policies: [none] - X-Request-Id: [b74a2cfe-c18f-42d5-b966-dd8dabbcd286] - X-Runtime: ['0.149867'] + X-Request-Id: [0f41d973-d9b0-4e72-9f81-8c98d8ddfb40] + X-Runtime: ['0.158456'] X-XSS-Protection: [1; mode=block] - content-length: ['1616'] + content-length: ['1253'] status: {code: 200, message: OK} - request: body: null @@ -132,11 +130,9 @@ interactions: response: body: {string: 'event: update - data: {"id":"101999520584397869","created_at":"2019-04-27T18:19:29.079Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/101999520584397869","content":"it's - cool guy
","url":"http://localhost/@mastodonpy_test/101999520584397869","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py - test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John - Lennon","locked":true,"bot":false,"created_at":"2019-04-27T20:03:12.393Z","note":"I - walk funny
","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","avatar_static":"http://localhost/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","header":"http://localhost/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","header_static":"http://localhost/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg?1556389071","followers_count":0,"following_count":0,"statuses_count":63,"emojis":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null} + data: {"id":"102000826367266958","created_at":"2019-04-27T23:51:33.747Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102000826367266958","content":"it's + cool guy
","url":"http://localhost/@mastodonpy_test/102000826367266958","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":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":"","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":3,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null} :'} @@ -146,9 +142,9 @@ interactions: Access-Control-Allow-Origin: ['*'] Connection: [keep-alive] Content-Type: [text/event-stream] - Date: ['Sat, 27 Apr 2019 18:19:29 GMT'] + Date: ['Sat, 27 Apr 2019 23:51:33 GMT'] Transfer-Encoding: [chunked] X-Powered-By: [Express] - X-Request-Id: [1545b4dd-c428-4904-8db3-b5f4af9908c3] + X-Request-Id: [d39b3ece-b7de-459d-8cea-f55d018ce010] status: {code: 200, message: OK} version: 1