mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 17:26:46 +00:00
fix: Wait for ws logs test to init
This commit is contained in:
parent
5f3fc0d96e
commit
4ca9b9f54e
|
@ -1,3 +1,5 @@
|
||||||
|
import asyncio
|
||||||
|
import pytest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from systemd import journal
|
from systemd import journal
|
||||||
|
|
||||||
|
@ -135,7 +137,8 @@ def test_graphql_get_logs_with_down_border(authorized_client):
|
||||||
assert_log_entry_equals_to_journal_entry(api_entry, journal_entry)
|
assert_log_entry_equals_to_journal_entry(api_entry, journal_entry)
|
||||||
|
|
||||||
|
|
||||||
def test_websocket_subscription_for_logs(authorized_client):
|
@pytest.mark.asyncio
|
||||||
|
async def test_websocket_subscription_for_logs(authorized_client):
|
||||||
with authorized_client.websocket_connect(
|
with authorized_client.websocket_connect(
|
||||||
"/graphql", subprotocols=["graphql-transport-ws"]
|
"/graphql", subprotocols=["graphql-transport-ws"]
|
||||||
) as websocket:
|
) as websocket:
|
||||||
|
@ -149,6 +152,7 @@ def test_websocket_subscription_for_logs(authorized_client):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
def read_until(message, limit=5):
|
def read_until(message, limit=5):
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -159,6 +163,7 @@ def test_websocket_subscription_for_logs(authorized_client):
|
||||||
if msg == message:
|
if msg == message:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
i += 1
|
||||||
continue
|
continue
|
||||||
raise Exception("Failed to read websocket data, timeout")
|
raise Exception("Failed to read websocket data, timeout")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue