示例#1
0
    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)
示例#2
0
    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"
示例#3
0
    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
        )
示例#4
0
    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"
示例#5
0
    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)
示例#6
0
    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'
示例#7
0
文件: websocket_test.py 项目: gnott/h
    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)
示例#8
0
文件: websocket_test.py 项目: gnott/h
    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'