Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /mardiros_fastlife /tests /unittests /app /test_websocket.py
| import pytest | |
| from fastapi import FastAPI | |
| from fastapi.testclient import TestClient | |
| def wsclient(app: FastAPI): | |
| return TestClient(app, headers={"Authorization": "Bearer abc"}) | |
| def test_websocket_json(wsclient: TestClient): | |
| with wsclient.websocket_connect("/ws/json") as websocket: | |
| data = websocket.receive_json() | |
| assert data == {"msg": "Hello testserver.local"} | |
| websocket.send_json({"msg": "Hello from test"}) | |
| data = websocket.receive_json() | |
| assert data == {"msg": "Hello from test"} | |
| def test_websocket_text(wsclient: TestClient): | |
| with wsclient.websocket_connect("/ws/text") as websocket: | |
| data = websocket.receive_text() | |
| assert data == "Hello testserver.local" | |
| websocket.send_text("Hello from test") | |
| data = websocket.receive_text() | |
| assert data == "Hello from test" | |
| def test_websocket_bytes(wsclient: TestClient): | |
| with wsclient.websocket_connect("/ws/bytes") as websocket: | |
| data = websocket.receive_bytes() | |
| assert data == b"Hello testserver.local" | |
| websocket.send_bytes(b"Hello from test") | |
| data = websocket.receive_bytes() | |
| assert data == b"Hello from test" | |
Xet Storage Details
- Size:
- 1.21 kB
- Xet hash:
- 7398c91cc50d1eac1bd440be88d7e9cf1f52ccef3dfd3ba190c1587eea778d0c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.