Home / Function/ test_websocket_with_cookie() — fastapi Function Reference

test_websocket_with_cookie() — fastapi Function Reference

Architecture documentation for the test_websocket_with_cookie() function in test_tutorial002.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  9e9edbfc_85b1_a119_a6f6_cd917f36d891["test_websocket_with_cookie()"]
  45a8bc94_3841_f038_9f98_489f355c96bd["test_tutorial002.py"]
  9e9edbfc_85b1_a119_a6f6_cd917f36d891 -->|defined in| 45a8bc94_3841_f038_9f98_489f355c96bd
  style 9e9edbfc_85b1_a119_a6f6_cd917f36d891 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_tutorial/test_websockets/test_tutorial002.py lines 33–48

def test_websocket_with_cookie(app: FastAPI):
    client = TestClient(app, cookies={"session": "fakesession"})
    with pytest.raises(WebSocketDisconnect):
        with client.websocket_connect("/items/foo/ws") as websocket:
            message = "Message one"
            websocket.send_text(message)
            data = websocket.receive_text()
            assert data == "Session cookie or query token value is: fakesession"
            data = websocket.receive_text()
            assert data == f"Message text was: {message}, for item ID: foo"
            message = "Message two"
            websocket.send_text(message)
            data = websocket.receive_text()
            assert data == "Session cookie or query token value is: fakesession"
            data = websocket.receive_text()
            assert data == f"Message text was: {message}, for item ID: foo"

Domain

Subdomains

Frequently Asked Questions

What does test_websocket_with_cookie() do?
test_websocket_with_cookie() is a function in the fastapi codebase, defined in tests/test_tutorial/test_websockets/test_tutorial002.py.
Where is test_websocket_with_cookie() defined?
test_websocket_with_cookie() is defined in tests/test_tutorial/test_websockets/test_tutorial002.py at line 33.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free