-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import pytest | ||
from fastapi.testclient import TestClient | ||
|
||
from tests.conftest import test_rooms | ||
|
||
TEST_MESSAGE = "Is this websocket working ?" | ||
|
||
|
||
@pytest.mark.parametrize("room", test_rooms()) | ||
def test_websocket_put_message(client: TestClient, room: str): | ||
with client.websocket_connect(f"/room/{room}/ws") as websocket: | ||
client.put( | ||
f"/room/{room}/message", | ||
json={"message": TEST_MESSAGE, "author": f"ws-tester-{room}"}, | ||
) | ||
data = websocket.receive_json() | ||
assert data == {"message": TEST_MESSAGE, "author": f"ws-tester-{room}"} | ||
|
||
|
||
@pytest.mark.parametrize("room", test_rooms()) | ||
def test_websocket_send_message(client: TestClient, room: str): | ||
with client.websocket_connect(f"/room/{room}/ws") as websocket: | ||
websocket.send_json({"message": TEST_MESSAGE, "author": f"ws-tester-{room}"}) | ||
data = websocket.receive_json() | ||
assert data == {"message": TEST_MESSAGE, "author": f"ws-tester-{room}"} |