diff options
-rw-r--r-- | tests/cassettes/test_stream_user.yaml | 98 | ||||
-rw-r--r-- | tests/cassettes/test_stream_user_local.yaml | 178 | ||||
-rw-r--r-- | tests/test_streaming.py | 55 |
3 files changed, 288 insertions, 43 deletions
diff --git a/tests/cassettes/test_stream_user.yaml b/tests/cassettes/test_stream_user.yaml index eb378d2..52174df 100644 --- a/tests/cassettes/test_stream_user.yaml +++ b/tests/cassettes/test_stream_user.yaml | |||
@@ -10,17 +10,17 @@ interactions: | |||
10 | method: GET | 10 | method: GET |
11 | uri: http://localhost:3000/api/v1/instance/ | 11 | uri: http://localhost:3000/api/v1/instance/ |
12 | response: | 12 | response: |
13 | body: {string: '{"uri":"localhost:3000","title":"Mastodon","description":"","email":"","version":"2.3.3","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":163,"domain_count":0},"thumbnail":"http://localhost:3000/packs/preview.jpg","languages":["en"],"contact_account":null}'} | 13 | body: {string: '{"uri":"localhost:3000","title":"Mastodon","description":"","email":"","version":"2.3.3","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":171,"domain_count":0},"thumbnail":"http://localhost:3000/packs/preview.jpg","languages":["en"],"contact_account":null}'} |
14 | headers: | 14 | headers: |
15 | Cache-Control: ['max-age=0, private, must-revalidate'] | 15 | Cache-Control: ['max-age=0, private, must-revalidate'] |
16 | Content-Type: [application/json; charset=utf-8] | 16 | Content-Type: [application/json; charset=utf-8] |
17 | ETag: [W/"2cc4eba842d06668a5e9f36dd5e75e0b"] | 17 | ETag: [W/"0283a67545a9e43efc083c8db0db67d5"] |
18 | Transfer-Encoding: [chunked] | 18 | Transfer-Encoding: [chunked] |
19 | Vary: ['Accept-Encoding, Origin'] | 19 | Vary: ['Accept-Encoding, Origin'] |
20 | X-Content-Type-Options: [nosniff] | 20 | X-Content-Type-Options: [nosniff] |
21 | X-Frame-Options: [SAMEORIGIN] | 21 | X-Frame-Options: [SAMEORIGIN] |
22 | X-Request-Id: [58fc9460-3f90-4bdc-bfae-97b4792cdf72] | 22 | X-Request-Id: [20bc305c-8462-4fba-bdac-4e613388a8f7] |
23 | X-Runtime: ['0.030782'] | 23 | X-Runtime: ['0.037274'] |
24 | X-XSS-Protection: [1; mode=block] | 24 | X-XSS-Protection: [1; mode=block] |
25 | content-length: ['293'] | 25 | content-length: ['293'] |
26 | status: {code: 200, message: OK} | 26 | status: {code: 200, message: OK} |
@@ -37,21 +37,21 @@ interactions: | |||
37 | method: POST | 37 | method: POST |
38 | uri: http://localhost:3000/api/v1/statuses | 38 | uri: http://localhost:3000/api/v1/statuses |
39 | response: | 39 | response: |
40 | body: {string: '{"id":"99979315699876567","created_at":"2018-05-05T23:34:48.888Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979315699876567","content":"\u003cp\u003eonly | 40 | body: {string: '{"id":"99979409266681372","created_at":"2018-05-05T23:58:36.604Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979409266681372","content":"\u003cp\u003eonly |
41 | real cars respond.\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/99979315699876567","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | 41 | real cars respond.\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/99979409266681372","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py |
42 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John | 42 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John |
43 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"\u003cp\u003eI | 43 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"\u003cp\u003eI |
44 | walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":126},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} | 44 | walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":128},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} |
45 | headers: | 45 | headers: |
46 | Cache-Control: ['max-age=0, private, must-revalidate'] | 46 | Cache-Control: ['max-age=0, private, must-revalidate'] |
47 | Content-Type: [application/json; charset=utf-8] | 47 | Content-Type: [application/json; charset=utf-8] |
48 | ETag: [W/"3c8a52db795c6a852e9e7a21e7d912f4"] | 48 | ETag: [W/"3d64477a2e2beb52c14baba51ccd1490"] |
49 | Transfer-Encoding: [chunked] | 49 | Transfer-Encoding: [chunked] |
50 | Vary: ['Accept-Encoding, Origin'] | 50 | Vary: ['Accept-Encoding, Origin'] |
51 | X-Content-Type-Options: [nosniff] | 51 | X-Content-Type-Options: [nosniff] |
52 | X-Frame-Options: [SAMEORIGIN] | 52 | X-Frame-Options: [SAMEORIGIN] |
53 | X-Request-Id: [1f6725bf-2550-450f-bba5-d3967b33b7dc] | 53 | X-Request-Id: [0eb11335-9d45-4842-800d-dc4a2bb100dd] |
54 | X-Runtime: ['0.147682'] | 54 | X-Runtime: ['0.161381'] |
55 | X-XSS-Protection: [1; mode=block] | 55 | X-XSS-Protection: [1; mode=block] |
56 | content-length: ['1416'] | 56 | content-length: ['1416'] |
57 | status: {code: 200, message: OK} | 57 | status: {code: 200, message: OK} |
@@ -68,21 +68,21 @@ interactions: | |||
68 | method: POST | 68 | method: POST |
69 | uri: http://localhost:3000/api/v1/statuses | 69 | uri: http://localhost:3000/api/v1/statuses |
70 | response: | 70 | response: |
71 | body: {string: '{"id":"99979315714058991","created_at":"2018-05-05T23:34:49.170Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99979315714058991","content":"\u003cp\u003e\u003cspan | 71 | body: {string: '{"id":"99979409284606875","created_at":"2018-05-05T23:58:36.908Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99979409284606875","content":"\u003cp\u003e\u003cspan |
72 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" | 72 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" |
73 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e | 73 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e |
74 | beep beep I\u0026apos;m a jeep\u003c/p\u003e","url":"http://localhost:3000/@admin/99979315714058991","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | 74 | beep beep I\u0026apos;m a jeep\u003c/p\u003e","url":"http://localhost:3000/@admin/99979409284606875","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py |
75 | test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":39},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}'} | 75 | test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":45},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}'} |
76 | headers: | 76 | headers: |
77 | Cache-Control: ['max-age=0, private, must-revalidate'] | 77 | Cache-Control: ['max-age=0, private, must-revalidate'] |
78 | Content-Type: [application/json; charset=utf-8] | 78 | Content-Type: [application/json; charset=utf-8] |
79 | ETag: [W/"9852f6d00e1e9011caad26f718aa286a"] | 79 | ETag: [W/"cf7a8881dce33f2860b9710db188792e"] |
80 | Transfer-Encoding: [chunked] | 80 | Transfer-Encoding: [chunked] |
81 | Vary: ['Accept-Encoding, Origin'] | 81 | Vary: ['Accept-Encoding, Origin'] |
82 | X-Content-Type-Options: [nosniff] | 82 | X-Content-Type-Options: [nosniff] |
83 | X-Frame-Options: [SAMEORIGIN] | 83 | X-Frame-Options: [SAMEORIGIN] |
84 | X-Request-Id: [703ca6b3-f3c1-4157-96d0-34c07140c177] | 84 | X-Request-Id: [aa1e3b21-7389-4099-80cd-2e148564b91f] |
85 | X-Runtime: ['0.348615'] | 85 | X-Runtime: ['0.478716'] |
86 | X-XSS-Protection: [1; mode=block] | 86 | X-XSS-Protection: [1; mode=block] |
87 | content-length: ['1476'] | 87 | content-length: ['1476'] |
88 | status: {code: 200, message: OK} | 88 | status: {code: 200, message: OK} |
@@ -99,19 +99,19 @@ interactions: | |||
99 | method: POST | 99 | method: POST |
100 | uri: http://localhost:3000/api/v1/statuses | 100 | uri: http://localhost:3000/api/v1/statuses |
101 | response: | 101 | response: |
102 | body: {string: '{"id":"99979315736933684","created_at":"2018-05-05T23:34:49.488Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99979315736933684","content":"\u003cp\u003eon | 102 | body: {string: '{"id":"99979409315536647","created_at":"2018-05-05T23:58:37.370Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99979409315536647","content":"\u003cp\u003eon |
103 | the internet, nobody knows you\u0026apos;re a plane\u003c/p\u003e","url":"http://localhost:3000/@admin/99979315736933684","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | 103 | the internet, nobody knows you\u0026apos;re a plane\u003c/p\u003e","url":"http://localhost:3000/@admin/99979409315536647","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py |
104 | test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":40},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} | 104 | test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":46},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} |
105 | headers: | 105 | headers: |
106 | Cache-Control: ['max-age=0, private, must-revalidate'] | 106 | Cache-Control: ['max-age=0, private, must-revalidate'] |
107 | Content-Type: [application/json; charset=utf-8] | 107 | Content-Type: [application/json; charset=utf-8] |
108 | ETag: [W/"28991dfce9a4da45ed0bc7c886a05ac7"] | 108 | ETag: [W/"9f9d619a35ba2872a5aea194e6f87f60"] |
109 | Transfer-Encoding: [chunked] | 109 | Transfer-Encoding: [chunked] |
110 | Vary: ['Accept-Encoding, Origin'] | 110 | Vary: ['Accept-Encoding, Origin'] |
111 | X-Content-Type-Options: [nosniff] | 111 | X-Content-Type-Options: [nosniff] |
112 | X-Frame-Options: [SAMEORIGIN] | 112 | X-Frame-Options: [SAMEORIGIN] |
113 | X-Request-Id: [1bc22f75-7163-44f7-9e7f-696b7da28fc8] | 113 | X-Request-Id: [ac2b5974-2346-4bbc-b7e5-4e856736f202] |
114 | X-Runtime: ['0.279044'] | 114 | X-Runtime: ['0.351930'] |
115 | X-XSS-Protection: [1; mode=block] | 115 | X-XSS-Protection: [1; mode=block] |
116 | content-length: ['1175'] | 116 | content-length: ['1175'] |
117 | status: {code: 200, message: OK} | 117 | status: {code: 200, message: OK} |
@@ -122,34 +122,56 @@ interactions: | |||
122 | Accept-Encoding: ['gzip, deflate'] | 122 | Accept-Encoding: ['gzip, deflate'] |
123 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | 123 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] |
124 | Connection: [keep-alive] | 124 | Connection: [keep-alive] |
125 | Content-Length: ['0'] | ||
126 | User-Agent: [python-requests/2.9.1] | ||
127 | method: DELETE | ||
128 | uri: http://localhost:3000/api/v1/statuses/99979409266681372 | ||
129 | response: | ||
130 | body: {string: '{}'} | ||
131 | headers: | ||
132 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
133 | Content-Type: [application/json; charset=utf-8] | ||
134 | ETag: [W/"902f10b5792b4c6bb0671da661310919"] | ||
135 | Transfer-Encoding: [chunked] | ||
136 | Vary: ['Accept-Encoding, Origin'] | ||
137 | X-Content-Type-Options: [nosniff] | ||
138 | X-Frame-Options: [SAMEORIGIN] | ||
139 | X-Request-Id: [2750fe2f-27eb-41ac-9dc2-d27dbdb25361] | ||
140 | X-Runtime: ['0.072466'] | ||
141 | X-XSS-Protection: [1; mode=block] | ||
142 | content-length: ['2'] | ||
143 | status: {code: 200, message: OK} | ||
144 | - request: | ||
145 | body: null | ||
146 | headers: | ||
147 | Accept: ['*/*'] | ||
148 | Accept-Encoding: ['gzip, deflate'] | ||
149 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
150 | Connection: [keep-alive] | ||
125 | User-Agent: [python-requests/2.9.1] | 151 | User-Agent: [python-requests/2.9.1] |
126 | method: GET | 152 | method: GET |
127 | uri: http://localhost:4000/api/v1/streaming/user | 153 | uri: http://localhost:4000/api/v1/streaming/user |
128 | response: | 154 | response: |
129 | body: {string: 'event: update | 155 | body: {string: 'event: update |
130 | 156 | ||
131 | data: {"id":"99979315699876567","created_at":"2018-05-05T23:34:48.888Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979315699876567","content":"<p>only | 157 | data: {"id":"99979409266681372","created_at":"2018-05-05T23:58:36.604Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979409266681372","content":"<p>only |
132 | real cars respond.</p>","url":"http://localhost:3000/@mastodonpy_test/99979315699876567","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | 158 | real cars respond.</p>","url":"http://localhost:3000/@mastodonpy_test/99979409266681372","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py |
133 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John | 159 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John |
134 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"<p>I | 160 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"<p>I |
135 | walk funny</p>","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":126},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]} | 161 | walk funny</p>","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":128},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]} |
136 | 162 | ||
137 | 163 | ||
138 | event: update | 164 | event: notification |
139 | 165 | ||
140 | data: {"id":"99979315699876567","created_at":"2018-05-05T23:34:48.888Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979315699876567","content":"<p>only | 166 | data: {"id":"101","type":"mention","created_at":"2018-05-05T23:58:37.010Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"<p></p>","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":45},"status":{"id":"99979409284606875","created_at":"2018-05-05T23:58:36.908Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99979409284606875","content":"<p><span |
141 | real cars respond.</p>","url":"http://localhost:3000/@mastodonpy_test/99979315699876567","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | 167 | class=\"h-card\"><a href=\"http://localhost:3000/@mastodonpy_test\" class=\"u-url |
142 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John | 168 | mention\">@<span>mastodonpy_test</span></a></span> beep beep I'm a jeep</p>","url":"http://localhost:3000/@admin/99979409284606875","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py |
143 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"<p>I | 169 | test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"<p></p>","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":45},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}} |
144 | walk funny</p>","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":126},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]} | ||
145 | 170 | ||
146 | 171 | ||
147 | event: notification | 172 | event: delete |
148 | 173 | ||
149 | data: {"id":"98","type":"mention","created_at":"2018-05-05T23:34:49.249Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"<p></p>","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":39},"status":{"id":"99979315714058991","created_at":"2018-05-05T23:34:49.170Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99979315714058991","content":"<p><span | 174 | data: 99979409266681372 |
150 | class=\"h-card\"><a href=\"http://localhost:3000/@mastodonpy_test\" class=\"u-url | ||
151 | mention\">@<span>mastodonpy_test</span></a></span> beep beep I'm a jeep</p>","url":"http://localhost:3000/@admin/99979315714058991","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py | ||
152 | test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"<p></p>","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":39},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}} | ||
153 | 175 | ||
154 | 176 | ||
155 | '} | 177 | '} |
@@ -159,9 +181,9 @@ interactions: | |||
159 | Access-Control-Allow-Origin: ['*'] | 181 | Access-Control-Allow-Origin: ['*'] |
160 | Connection: [keep-alive] | 182 | Connection: [keep-alive] |
161 | Content-Type: [text/event-stream] | 183 | Content-Type: [text/event-stream] |
162 | Date: ['Sat, 05 May 2018 23:34:49 GMT'] | 184 | Date: ['Sat, 05 May 2018 23:58:36 GMT'] |
163 | Transfer-Encoding: [chunked] | 185 | Transfer-Encoding: [chunked] |
164 | X-Powered-By: [Express] | 186 | X-Powered-By: [Express] |
165 | X-Request-Id: [6ad697a2-e602-43fd-84b6-7676c3355d8f] | 187 | X-Request-Id: [bc14a253-bae4-436f-b7e4-420a9a9378c9] |
166 | status: {code: 200, message: OK} | 188 | status: {code: 200, message: OK} |
167 | version: 1 | 189 | version: 1 |
diff --git a/tests/cassettes/test_stream_user_local.yaml b/tests/cassettes/test_stream_user_local.yaml new file mode 100644 index 0000000..0b7b172 --- /dev/null +++ b/tests/cassettes/test_stream_user_local.yaml | |||
@@ -0,0 +1,178 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: null | ||
4 | headers: | ||
5 | Accept: ['*/*'] | ||
6 | Accept-Encoding: ['gzip, deflate'] | ||
7 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
8 | Connection: [keep-alive] | ||
9 | User-Agent: [python-requests/2.9.1] | ||
10 | method: GET | ||
11 | uri: http://localhost:3000/api/v1/instance/ | ||
12 | response: | ||
13 | body: {string: '{"uri":"localhost:3000","title":"Mastodon","description":"","email":"","version":"2.3.3","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":168,"domain_count":0},"thumbnail":"http://localhost:3000/packs/preview.jpg","languages":["en"],"contact_account":null}'} | ||
14 | headers: | ||
15 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
16 | Content-Type: [application/json; charset=utf-8] | ||
17 | ETag: [W/"9dcdc369320d2f0c962f1a06daed8db9"] | ||
18 | Transfer-Encoding: [chunked] | ||
19 | Vary: ['Accept-Encoding, Origin'] | ||
20 | X-Content-Type-Options: [nosniff] | ||
21 | X-Frame-Options: [SAMEORIGIN] | ||
22 | X-Request-Id: [2429f21b-a558-47f9-8bd3-4d3084a2680b] | ||
23 | X-Runtime: ['0.041377'] | ||
24 | X-XSS-Protection: [1; mode=block] | ||
25 | content-length: ['293'] | ||
26 | status: {code: 200, message: OK} | ||
27 | - request: | ||
28 | body: status=it%27s+cool+guy | ||
29 | headers: | ||
30 | Accept: ['*/*'] | ||
31 | Accept-Encoding: ['gzip, deflate'] | ||
32 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
33 | Connection: [keep-alive] | ||
34 | Content-Length: ['22'] | ||
35 | Content-Type: [application/x-www-form-urlencoded] | ||
36 | User-Agent: [python-requests/2.9.1] | ||
37 | method: POST | ||
38 | uri: http://localhost:3000/api/v1/statuses | ||
39 | response: | ||
40 | body: {string: '{"id":"99979403680236480","created_at":"2018-05-05T23:57:11.361Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"fy","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979403680236480","content":"\u003cp\u003eit\u0026apos;s | ||
41 | cool guy\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/99979403680236480","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | ||
42 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John | ||
43 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"\u003cp\u003eI | ||
44 | walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":127},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} | ||
45 | headers: | ||
46 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
47 | Content-Type: [application/json; charset=utf-8] | ||
48 | ETag: [W/"121605cb0579eff7d8201d992e4d2cb1"] | ||
49 | Transfer-Encoding: [chunked] | ||
50 | Vary: ['Accept-Encoding, Origin'] | ||
51 | X-Content-Type-Options: [nosniff] | ||
52 | X-Frame-Options: [SAMEORIGIN] | ||
53 | X-Request-Id: [e3123208-a5d0-47b5-82f4-fef3bc5054a5] | ||
54 | X-Runtime: ['0.147603'] | ||
55 | X-XSS-Protection: [1; mode=block] | ||
56 | content-length: ['1416'] | ||
57 | status: {code: 200, message: OK} | ||
58 | - request: | ||
59 | body: null | ||
60 | headers: | ||
61 | Accept: ['*/*'] | ||
62 | Accept-Encoding: ['gzip, deflate'] | ||
63 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
64 | Connection: [keep-alive] | ||
65 | User-Agent: [python-requests/2.9.1] | ||
66 | method: GET | ||
67 | uri: http://localhost:4000/api/v1/streaming/user | ||
68 | response: | ||
69 | body: {string: 'event: update | ||
70 | |||
71 | data: {"id":"99979403680236480","created_at":"2018-05-05T23:57:11.361Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"fy","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979403680236480","content":"<p>it's | ||
72 | cool guy</p>","url":"http://localhost:3000/@mastodonpy_test/99979403680236480","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | ||
73 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John | ||
74 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"<p>I | ||
75 | walk funny</p>","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":127},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]} | ||
76 | |||
77 | |||
78 | '} | ||
79 | headers: | ||
80 | Access-Control-Allow-Headers: ['Authorization, Accept, Cache-Control'] | ||
81 | Access-Control-Allow-Methods: ['GET, OPTIONS'] | ||
82 | Access-Control-Allow-Origin: ['*'] | ||
83 | Connection: [keep-alive] | ||
84 | Content-Type: [text/event-stream] | ||
85 | Date: ['Sat, 05 May 2018 23:57:11 GMT'] | ||
86 | Transfer-Encoding: [chunked] | ||
87 | X-Powered-By: [Express] | ||
88 | X-Request-Id: [78347150-7ae6-453d-a423-187c71c50b2b] | ||
89 | status: {code: 200, message: OK} | ||
90 | - request: | ||
91 | body: null | ||
92 | headers: | ||
93 | Accept: ['*/*'] | ||
94 | Accept-Encoding: ['gzip, deflate'] | ||
95 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
96 | Connection: [keep-alive] | ||
97 | User-Agent: [python-requests/2.9.1] | ||
98 | method: GET | ||
99 | uri: http://localhost:3000/api/v1/instance/ | ||
100 | response: | ||
101 | body: {string: '{"uri":"localhost:3000","title":"Mastodon","description":"","email":"","version":"2.3.3","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":173,"domain_count":0},"thumbnail":"http://localhost:3000/packs/preview.jpg","languages":["en"],"contact_account":null}'} | ||
102 | headers: | ||
103 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
104 | Content-Type: [application/json; charset=utf-8] | ||
105 | ETag: [W/"4ea0e36d646260365a2d1414798974a6"] | ||
106 | Transfer-Encoding: [chunked] | ||
107 | Vary: ['Accept-Encoding, Origin'] | ||
108 | X-Content-Type-Options: [nosniff] | ||
109 | X-Frame-Options: [SAMEORIGIN] | ||
110 | X-Request-Id: [e8c8246d-d382-41d9-b7f1-d11fb0b74711] | ||
111 | X-Runtime: ['0.455622'] | ||
112 | X-XSS-Protection: [1; mode=block] | ||
113 | content-length: ['293'] | ||
114 | status: {code: 200, message: OK} | ||
115 | - request: | ||
116 | body: status=it%27s+cool+guy | ||
117 | headers: | ||
118 | Accept: ['*/*'] | ||
119 | Accept-Encoding: ['gzip, deflate'] | ||
120 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
121 | Connection: [keep-alive] | ||
122 | Content-Length: ['22'] | ||
123 | Content-Type: [application/x-www-form-urlencoded] | ||
124 | User-Agent: [python-requests/2.9.1] | ||
125 | method: POST | ||
126 | uri: http://localhost:3000/api/v1/statuses | ||
127 | response: | ||
128 | body: {string: '{"id":"99979411114866656","created_at":"2018-05-05T23:59:04.956Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"fy","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979411114866656","content":"\u003cp\u003eit\u0026apos;s | ||
129 | cool guy\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/99979411114866656","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | ||
130 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John | ||
131 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"\u003cp\u003eI | ||
132 | walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":128},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} | ||
133 | headers: | ||
134 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
135 | Content-Type: [application/json; charset=utf-8] | ||
136 | ETag: [W/"37bc69af5d0ef985756917c50ebd21e9"] | ||
137 | Transfer-Encoding: [chunked] | ||
138 | Vary: ['Accept-Encoding, Origin'] | ||
139 | X-Content-Type-Options: [nosniff] | ||
140 | X-Frame-Options: [SAMEORIGIN] | ||
141 | X-Request-Id: [64080bdc-dd95-409c-a2ac-b24b5207ca86] | ||
142 | X-Runtime: ['0.553667'] | ||
143 | X-XSS-Protection: [1; mode=block] | ||
144 | content-length: ['1416'] | ||
145 | status: {code: 200, message: OK} | ||
146 | - request: | ||
147 | body: null | ||
148 | headers: | ||
149 | Accept: ['*/*'] | ||
150 | Accept-Encoding: ['gzip, deflate'] | ||
151 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
152 | Connection: [keep-alive] | ||
153 | User-Agent: [python-requests/2.9.1] | ||
154 | method: GET | ||
155 | uri: http://localhost:4000/api/v1/streaming/user | ||
156 | response: | ||
157 | body: {string: 'event: update | ||
158 | |||
159 | data: {"id":"99979411114866656","created_at":"2018-05-05T23:59:04.956Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"fy","uri":"http://localhost:3000/users/mastodonpy_test/statuses/99979411114866656","content":"<p>it's | ||
160 | cool guy</p>","url":"http://localhost:3000/@mastodonpy_test/99979411114866656","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | ||
161 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John | ||
162 | Lennon","locked":true,"created_at":"2018-04-18T20:04:06.511Z","note":"<p>I | ||
163 | walk funny</p>","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":128},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]} | ||
164 | |||
165 | |||
166 | '} | ||
167 | headers: | ||
168 | Access-Control-Allow-Headers: ['Authorization, Accept, Cache-Control'] | ||
169 | Access-Control-Allow-Methods: ['GET, OPTIONS'] | ||
170 | Access-Control-Allow-Origin: ['*'] | ||
171 | Connection: [keep-alive] | ||
172 | Content-Type: [text/event-stream] | ||
173 | Date: ['Sat, 05 May 2018 23:59:05 GMT'] | ||
174 | Transfer-Encoding: [chunked] | ||
175 | X-Powered-By: [Express] | ||
176 | X-Request-Id: [824c3f23-264a-44cd-8c2a-55bf888c5ed3] | ||
177 | status: {code: 200, message: OK} | ||
178 | version: 1 | ||
diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 8c2160a..883b773 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py | |||
@@ -154,6 +154,15 @@ def test_unknown_event(): | |||
154 | assert listener.deletes == [] | 154 | assert listener.deletes == [] |
155 | assert listener.heartbeats == 0 | 155 | assert listener.heartbeats == 0 |
156 | 156 | ||
157 | def test_invalid_event(): | ||
158 | """But not too tolerant""" | ||
159 | listener = Listener() | ||
160 | with pytest.raises(MastodonMalformedEventError): | ||
161 | listener.handle_stream_([ | ||
162 | 'event: whatup', | ||
163 | 'data: {}', | ||
164 | '', | ||
165 | ]) | ||
157 | 166 | ||
158 | def test_missing_event_name(): | 167 | def test_missing_event_name(): |
159 | listener = Listener() | 168 | listener = Listener() |
@@ -257,9 +266,11 @@ def test_stream_user(api, api2): | |||
257 | 266 | ||
258 | updates = [] | 267 | updates = [] |
259 | notifications = [] | 268 | notifications = [] |
269 | deletes = [] | ||
260 | listener = CallbackStreamListener( | 270 | listener = CallbackStreamListener( |
261 | update_handler = lambda x: updates.append(x), | 271 | update_handler = lambda x: updates.append(x), |
262 | notification_handler = lambda x: notifications.append(x) | 272 | notification_handler = lambda x: notifications.append(x), |
273 | delete_handler = lambda x: deletes.append(x) | ||
263 | ) | 274 | ) |
264 | 275 | ||
265 | posted = [] | 276 | posted = [] |
@@ -268,7 +279,9 @@ def test_stream_user(api, api2): | |||
268 | posted.append(api.status_post("only real cars respond.")) | 279 | posted.append(api.status_post("only real cars respond.")) |
269 | posted.append(api2.status_post("@mastodonpy_test beep beep I'm a jeep")) | 280 | posted.append(api2.status_post("@mastodonpy_test beep beep I'm a jeep")) |
270 | posted.append(api2.status_post("on the internet, nobody knows you're a plane")) | 281 | posted.append(api2.status_post("on the internet, nobody knows you're a plane")) |
271 | time.sleep(3) | 282 | time.sleep(1) |
283 | api.status_delete(posted[0]) | ||
284 | time.sleep(2) | ||
272 | streamingClose() | 285 | streamingClose() |
273 | 286 | ||
274 | t = threading.Thread(args=(), target=do_activities) | 287 | t = threading.Thread(args=(), target=do_activities) |
@@ -282,13 +295,45 @@ def test_stream_user(api, api2): | |||
282 | if stream != None: | 295 | if stream != None: |
283 | stream.close() | 296 | stream.close() |
284 | 297 | ||
285 | assert len(updates) == 2 | 298 | assert len(updates) == 1 |
286 | assert len(notifications) == 1 | 299 | assert len(notifications) == 1 |
300 | assert len(deletes) == 1 | ||
287 | 301 | ||
288 | assert updates[0].id == posted[0].id | 302 | assert updates[0].id == posted[0].id |
289 | assert updates[1].id == posted[0].id | 303 | assert deletes[0] == posted[0].id |
290 | assert notifications[0].status.id == posted[1].id | 304 | assert notifications[0].status.id == posted[1].id |
291 | 305 | ||
292 | t.join() | 306 | t.join() |
293 | 307 | ||
294 | \ No newline at end of file | 308 | @pytest.mark.vcr(match_on=['path']) |
309 | def test_stream_user_local(api, api2): | ||
310 | patchStreaming() | ||
311 | |||
312 | updates = [] | ||
313 | notifications = [] | ||
314 | listener = CallbackStreamListener( | ||
315 | local_update_handler = lambda x: updates.append(x), | ||
316 | ) | ||
317 | |||
318 | posted = [] | ||
319 | def do_activities(): | ||
320 | time.sleep(5) | ||
321 | posted.append(api.status_post("it's cool guy")) | ||
322 | time.sleep(3) | ||
323 | streamingClose() | ||
324 | |||
325 | t = threading.Thread(args=(), target=do_activities) | ||
326 | t.start() | ||
327 | |||
328 | stream = None | ||
329 | try: | ||
330 | stream = api.stream_user(listener, run_async=True) | ||
331 | time.sleep(13) | ||
332 | finally: | ||
333 | if stream != None: | ||
334 | stream.close() | ||
335 | |||
336 | assert len(updates) == 1 | ||
337 | assert updates[0].id == posted[0].id | ||
338 | |||
339 | t.join() \ No newline at end of file | ||