|
|
|
@ -1,4 +1,5 @@ |
|
|
|
import importlib |
|
|
|
import time |
|
|
|
from types import ModuleType |
|
|
|
|
|
|
|
import pytest |
|
|
|
@ -42,11 +43,13 @@ def test_websocket_handle_disconnection(client: TestClient): |
|
|
|
connection.send_text("Hello from 1234") |
|
|
|
data1 = connection.receive_text() |
|
|
|
assert data1 == "You wrote: Hello from 1234" |
|
|
|
time.sleep(0.01) # Give server time to process broadcast |
|
|
|
data2 = connection_two.receive_text() |
|
|
|
client1_says = "Client #1234 says: Hello from 1234" |
|
|
|
assert data2 == client1_says |
|
|
|
data1 = connection.receive_text() |
|
|
|
assert data1 == client1_says |
|
|
|
connection_two.close() |
|
|
|
time.sleep(0.01) # Give server time to process broadcast |
|
|
|
data1 = connection.receive_text() |
|
|
|
assert data1 == "Client #5678 left the chat" |
|
|
|
|