23 lines
938 B
Python
23 lines
938 B
Python
from conftest import create_session, join_student
|
|
|
|
|
|
def test_reconnect_replays_existing_submit_ack(client, sample_pool):
|
|
sid = create_session(client, sample_pool)
|
|
join_student(client, sid, "s1", "Student One")
|
|
rooms = client.app.state.rooms
|
|
client.portal.call(rooms.open_question, sid, 0, 2)
|
|
|
|
with client.websocket_connect(f"/ws/student/{sid}") as ws:
|
|
assert ws.receive_json()["type"] == "state"
|
|
assert ws.receive_json()["type"] == "question_open"
|
|
ws.send_json({"type": "submit", "question_idx": 0, "answer": "B"})
|
|
ack = ws.receive_json()
|
|
assert ack["type"] == "submit_ack"
|
|
|
|
with client.websocket_connect(f"/ws/student/{sid}") as ws:
|
|
assert ws.receive_json()["type"] == "state"
|
|
assert ws.receive_json()["type"] == "question_open"
|
|
replay = ws.receive_json()
|
|
assert replay["type"] == "submit_ack"
|
|
assert replay["score"] == ack["score"]
|