aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_streaming.py')
-rw-r--r--tests/test_streaming.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/tests/test_streaming.py b/tests/test_streaming.py
index a471c41..cddb79a 100644
--- a/tests/test_streaming.py
+++ b/tests/test_streaming.py
@@ -17,7 +17,7 @@ streaming_is_patched = False
17real_connections = [] 17real_connections = []
18close_connections = False 18close_connections = False
19 19
20def patchStreaming(): 20def patch_streaming():
21 global streaming_is_patched 21 global streaming_is_patched
22 global close_connections 22 global close_connections
23 if streaming_is_patched == True: 23 if streaming_is_patched == True:
@@ -281,7 +281,7 @@ def test_multiline_payload():
281 281
282@pytest.mark.vcr(match_on=['path']) 282@pytest.mark.vcr(match_on=['path'])
283def test_stream_user(api, api2): 283def test_stream_user(api, api2):
284 patchStreaming() 284 patch_streaming()
285 285
286 # Make sure we are in the right state to not receive updates from api2 286 # Make sure we are in the right state to not receive updates from api2
287 user = api2.account_verify_credentials() 287 user = api2.account_verify_credentials()
@@ -331,7 +331,7 @@ def test_stream_user(api, api2):
331 331
332@pytest.mark.vcr(match_on=['path']) 332@pytest.mark.vcr(match_on=['path'])
333def test_stream_user_local(api, api2): 333def test_stream_user_local(api, api2):
334 patchStreaming() 334 patch_streaming()
335 335
336 # Make sure we are in the right state to not receive updates from api2 336 # Make sure we are in the right state to not receive updates from api2
337 user = api2.account_verify_credentials() 337 user = api2.account_verify_credentials()
@@ -366,6 +366,34 @@ def test_stream_user_local(api, api2):
366 366
367 t.join() 367 t.join()
368 368
369@pytest.mark.vcr(match_on=['path'])
370def test_stream_direct(api, api2):
371 patch_streaming()
372
373 conversations = []
374 listener = CallbackStreamListener(
375 conversation_handler = lambda x: conversations.append(x),
376 )
377
378 def do_activities():
379 time.sleep(5)
380 api2.status_post("@mastodonpy_test todo funny text here", visibility = "direct")
381 time.sleep(10)
382 streaming_close()
383
384 t = threading.Thread(args=(), target=do_activities)
385 t.start()
386
387 stream = None
388 try:
389 stream = api.stream_direct(listener, run_async=True)
390 time.sleep(20)
391 finally:
392 if stream != None:
393 stream.close()
394
395 assert len(conversations) == 1
396
369@pytest.mark.vcr() 397@pytest.mark.vcr()
370def test_stream_healthy(api_anonymous): 398def test_stream_healthy(api_anonymous):
371 assert api_anonymous.stream_healthy() 399 assert api_anonymous.stream_healthy()
Powered by cgit v1.2.3 (git 2.41.0)