mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-10 01:49:32 +00:00
test(websocket): remove some duplication
This commit is contained in:
parent
57378a7940
commit
41f6d8b6d2
|
@ -34,6 +34,18 @@ jobUpdates {
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def api_subscribe(websocket, id, subscription):
|
||||||
|
websocket.send_json(
|
||||||
|
{
|
||||||
|
"id": id,
|
||||||
|
"type": "subscribe",
|
||||||
|
"payload": {
|
||||||
|
"query": "subscription TestSubscription {" + subscription + "}",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def connect_ws_authenticated(authorized_client) -> WebSocketTestSession:
|
def connect_ws_authenticated(authorized_client) -> WebSocketTestSession:
|
||||||
token = "Bearer " + str(DEVICE_WE_AUTH_TESTS_WITH["token"])
|
token = "Bearer " + str(DEVICE_WE_AUTH_TESTS_WITH["token"])
|
||||||
return authorized_client.websocket_connect(
|
return authorized_client.websocket_connect(
|
||||||
|
@ -104,24 +116,9 @@ def test_websocket_graphql_ping(authorized_client):
|
||||||
assert pong == {"type": "pong"}
|
assert pong == {"type": "pong"}
|
||||||
|
|
||||||
|
|
||||||
def api_subscribe(websocket, id, subscription):
|
def test_websocket_subscription_minimal(authorized_client, authenticated_websocket):
|
||||||
websocket.send_json(
|
|
||||||
{
|
|
||||||
"id": id,
|
|
||||||
"type": "subscribe",
|
|
||||||
"payload": {
|
|
||||||
"query": "subscription TestSubscription {" + subscription + "}",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_websocket_subscription_minimal(authorized_client):
|
|
||||||
# Test a small endpoint that exists specifically for tests
|
# Test a small endpoint that exists specifically for tests
|
||||||
client = authorized_client
|
websocket = authenticated_websocket
|
||||||
with client.websocket_connect(
|
|
||||||
"/graphql", subprotocols=["graphql-transport-ws"]
|
|
||||||
) as websocket:
|
|
||||||
init_graphql(websocket)
|
init_graphql(websocket)
|
||||||
arbitrary_id = "3aaa2445"
|
arbitrary_id = "3aaa2445"
|
||||||
api_subscribe(websocket, arbitrary_id, "count")
|
api_subscribe(websocket, arbitrary_id, "count")
|
||||||
|
|
Loading…
Reference in a new issue