diff options
author | halcy <halcy@ARARAGI-KUN> | 2022-11-07 23:11:30 +0200 |
---|---|---|
committer | halcy <halcy@ARARAGI-KUN> | 2022-11-07 23:11:30 +0200 |
commit | 3277ca777821e76955fb26d80788939a311db9db (patch) | |
tree | bef0749a451464d00e59fb3c685e6eb6d69a8a78 /tests/test_streaming.py | |
parent | 33d1e17e2e75884abd6e0a8a3e4a4da388e97e55 (diff) | |
download | mastodon.py-3277ca777821e76955fb26d80788939a311db9db.tar.gz |
Initial test fixing pass. Four tests still fail.
Diffstat (limited to 'tests/test_streaming.py')
-rw-r--r-- | tests/test_streaming.py | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 8912b9c..a22b184 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py | |||
@@ -323,7 +323,7 @@ def test_stream_user(api, api2): | |||
323 | 323 | ||
324 | # Make sure we are in the right state to not receive updates from api2 | 324 | # Make sure we are in the right state to not receive updates from api2 |
325 | user = api2.account_verify_credentials() | 325 | user = api2.account_verify_credentials() |
326 | api2.account_unfollow(user) | 326 | api.account_unfollow(user) |
327 | time.sleep(2) | 327 | time.sleep(2) |
328 | 328 | ||
329 | updates = [] | 329 | updates = [] |
@@ -349,13 +349,9 @@ def test_stream_user(api, api2): | |||
349 | t = threading.Thread(args=(), target=do_activities) | 349 | t = threading.Thread(args=(), target=do_activities) |
350 | t.start() | 350 | t.start() |
351 | 351 | ||
352 | stream = None | 352 | stream = api.stream_user(listener, run_async=True) |
353 | try: | 353 | time.sleep(20) |
354 | stream = api.stream_user(listener, run_async=True) | 354 | stream.close() |
355 | time.sleep(20) | ||
356 | finally: | ||
357 | if stream != None: | ||
358 | stream.close() | ||
359 | 355 | ||
360 | assert len(updates) == 1 | 356 | assert len(updates) == 1 |
361 | assert len(notifications) == 1 | 357 | assert len(notifications) == 1 |
@@ -373,10 +369,9 @@ def test_stream_user_local(api, api2): | |||
373 | 369 | ||
374 | # Make sure we are in the right state to not receive updates from api2 | 370 | # Make sure we are in the right state to not receive updates from api2 |
375 | user = api2.account_verify_credentials() | 371 | user = api2.account_verify_credentials() |
376 | api2.account_unfollow(user) | 372 | api.account_unfollow(user) |
377 | 373 | ||
378 | updates = [] | 374 | updates = [] |
379 | notifications = [] | ||
380 | listener = CallbackStreamListener( | 375 | listener = CallbackStreamListener( |
381 | local_update_handler = lambda x: updates.append(x), | 376 | local_update_handler = lambda x: updates.append(x), |
382 | ) | 377 | ) |
@@ -391,13 +386,9 @@ def test_stream_user_local(api, api2): | |||
391 | t = threading.Thread(args=(), target=do_activities) | 386 | t = threading.Thread(args=(), target=do_activities) |
392 | t.start() | 387 | t.start() |
393 | 388 | ||
394 | stream = None | 389 | stream = api.stream_user(listener, run_async=True) |
395 | try: | 390 | time.sleep(20) |
396 | stream = api.stream_user(listener, run_async=True) | 391 | stream.close() |
397 | time.sleep(20) | ||
398 | finally: | ||
399 | if stream != None: | ||
400 | stream.close() | ||
401 | 392 | ||
402 | assert len(updates) == 1 | 393 | assert len(updates) == 1 |
403 | assert updates[0].id == posted[0].id | 394 | assert updates[0].id == posted[0].id |
@@ -422,13 +413,9 @@ def test_stream_direct(api, api2): | |||
422 | t = threading.Thread(args=(), target=do_activities) | 413 | t = threading.Thread(args=(), target=do_activities) |
423 | t.start() | 414 | t.start() |
424 | 415 | ||
425 | stream = None | 416 | stream = api.stream_direct(listener, run_async=True) |
426 | try: | 417 | time.sleep(20) |
427 | stream = api.stream_direct(listener, run_async=True) | 418 | stream.close() |
428 | time.sleep(20) | ||
429 | finally: | ||
430 | if stream != None: | ||
431 | stream.close() | ||
432 | 419 | ||
433 | assert len(conversations) == 1 | 420 | assert len(conversations) == 1 |
434 | 421 | ||