def test_missing_value_error(self, socket): message = websocket.Message(socket=socket, payload={"messageType": "client_id"}) with mock.patch.object(websocket.Message, "reply") as mock_reply: websocket.handle_client_id_message(message) mock_reply.assert_called_once_with(Any.dict.containing(["error"]), ok=False)
def test_sets_client_id(self, socket): """Updates the socket client_id if valid.""" message = websocket.Message( socket=socket, payload={"messageType": "client_id", "value": "abcd1234"} ) websocket.handle_client_id_message(message) assert socket.client_id == "abcd1234"
def test_missing_value_error(self, matchers, socket): message = websocket.Message(socket=socket, payload={"messageType": "client_id"}) with mock.patch.object(websocket.Message, "reply") as mock_reply: websocket.handle_client_id_message(message) mock_reply.assert_called_once_with( matchers.MappingContaining("error"), ok=False )
def test_missing_value_error(self, matchers, socket): message = websocket.Message(socket=socket, payload={ 'messageType': 'client_id', }) with mock.patch.object(websocket.Message, 'reply') as mock_reply: websocket.handle_client_id_message(message) mock_reply.assert_called_once_with(matchers.MappingContaining('error'), ok=False)
def test_sets_client_id(self, socket): """Updates the socket client_id if valid.""" message = websocket.Message(socket=socket, payload={ 'messageType': 'client_id', 'value': 'abcd1234', }) websocket.handle_client_id_message(message) assert socket.client_id == 'abcd1234'
def test_missing_value_error(self, matchers, socket): message = websocket.Message(socket=socket, payload={ 'messageType': 'client_id', }) with mock.patch.object(websocket.Message, 'reply') as mock_reply: websocket.handle_client_id_message(message) mock_reply.assert_called_once_with(matchers.mapping_containing('error'), ok=False)