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