Exemplo n.º 1
0
    def test_replies_with_whoyouare_message(self, socket, userid):
        """Send back a `whoyouare` message with a userid (which may be null)."""
        socket.authenticated_userid = userid
        message = websocket.Message(socket=socket, payload={"type": "whoami"})

        with mock.patch.object(websocket.Message, "reply") as mock_reply:
            websocket.handle_whoami_message(message)

        mock_reply.assert_called_once_with({"type": "whoyouare", "userid": userid})
Exemplo n.º 2
0
    def test_replies_with_whoyouare_message(self, socket, userid):
        """Send back a `whoyouare` message with a userid (which may be null)."""
        socket.authenticated_userid = userid
        message = websocket.Message(socket=socket, payload={"type": "whoami"})

        with mock.patch.object(websocket.Message, "reply") as mock_reply:
            websocket.handle_whoami_message(message)

        mock_reply.assert_called_once_with({"type": "whoyouare", "userid": userid})
Exemplo n.º 3
0
    def test_replies_with_whoyouare_message(self, socket, with_identity):
        if not with_identity:
            socket.identity = False

        message = websocket.Message(socket=socket, payload={"type": "whoami"})

        with mock.patch.object(websocket.Message, "reply") as mock_reply:
            websocket.handle_whoami_message(message)

        mock_reply.assert_called_once_with({
            "type":
            "whoyouare",
            "userid":
            socket.identity.user.userid if with_identity else None,
        })