mirror of
https://github.com/ihabunek/toot
synced 2025-02-03 20:57:38 +01:00
Replace sleeps in tests with retries
This commit is contained in:
parent
301c8d21df
commit
d1fe0ca92d
@ -1,6 +1,7 @@
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
from tests.utils import run_with_retries
|
||||
|
||||
from toot import api, cli
|
||||
from toot.exceptions import NotFoundError
|
||||
@ -46,11 +47,11 @@ def test_favourite(app, user, run):
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status unfavourited"
|
||||
|
||||
# A short delay is required before the server returns new data
|
||||
time.sleep(0.2)
|
||||
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert not status["favourited"]
|
||||
def test_favourited():
|
||||
nonlocal status
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert not status["favourited"]
|
||||
run_with_retries(test_favourited)
|
||||
|
||||
|
||||
def test_favourite_json(app, user, run):
|
||||
|
@ -1,6 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from time import sleep
|
||||
from uuid import uuid4
|
||||
from tests.utils import run_with_retries
|
||||
|
||||
@ -165,13 +164,14 @@ def test_notifications(app, user, other_user, run):
|
||||
|
||||
text = f"Paging doctor @{user.username}"
|
||||
status = _post_status(app, other_user, text)
|
||||
sleep(0.5) # grr
|
||||
|
||||
result = run(cli.timelines.notifications)
|
||||
assert result.exit_code == 0
|
||||
assert f"@{other_user.username} mentioned you" in result.stdout
|
||||
assert status.id in result.stdout
|
||||
assert text in result.stdout
|
||||
def test_notifications():
|
||||
result = run(cli.timelines.notifications)
|
||||
assert result.exit_code == 0
|
||||
assert f"@{other_user.username} mentioned you" in result.stdout
|
||||
assert status.id in result.stdout
|
||||
assert text in result.stdout
|
||||
run_with_retries(test_notifications)
|
||||
|
||||
result = run(cli.timelines.notifications, "--mentions")
|
||||
assert result.exit_code == 0
|
||||
@ -185,7 +185,6 @@ def test_notifications_follow(app, user, friend_user, run_as):
|
||||
assert result.exit_code == 0
|
||||
assert f"@{user.username} now follows you" in result.stdout
|
||||
|
||||
|
||||
result = run_as(friend_user, cli.timelines.notifications, "--mentions")
|
||||
assert result.exit_code == 0
|
||||
assert "now follows you" not in result.stdout
|
||||
|
Loading…
x
Reference in New Issue
Block a user