示例#1
0
    def test_no_send_when_socket_is_not_event_users(self, socket, message):
        """Don't send session-change events if the event user is not the socket user."""
        message["userid"] = "amy"
        socket.authenticated_userid = "bob"

        messages.handle_user_event(message, [socket], None, None)

        socket.send_json.assert_not_called()
示例#2
0
    def test_no_send_when_socket_is_not_event_users(self):
        """Don't send session-change events if the event user is not the socket user."""
        message = {"type": "group-join", "userid": "amy", "group": "groupid"}
        socket = FakeSocket("clientid")
        socket.authenticated_userid = "bob"

        messages.handle_user_event(message, [socket], None, None)

        assert socket.send_json_payloads == []
示例#3
0
    def test_no_send_when_socket_is_not_event_users(self):
        """Don't send session-change events if the event user is not the socket user."""
        message = {"type": "group-join", "userid": "amy", "group": "groupid"}
        socket = FakeSocket("clientid")
        socket.authenticated_userid = "bob"

        messages.handle_user_event(message, [socket], None, None)

        assert socket.send_json_payloads == []
示例#4
0
    def test_no_send_when_socket_is_not_event_users(self):
        """Don't send session-change events if the event user is not the socket user."""
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
        }
        socket = FakeSocket('clientid')
        socket.authenticated_userid = 'bob'

        messages.handle_user_event(message, [socket], None, None)

        assert socket.send_json_payloads == []
示例#5
0
文件: messages_test.py 项目: ziqizh/h
    def test_no_send_when_socket_is_not_event_users(self):
        """Don't send session-change events if the event user is not the socket user."""
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
        }
        socket = FakeSocket('clientid')
        socket.authenticated_userid = 'bob'

        messages.handle_user_event(message, [socket], None, None)

        assert socket.send_json_payloads == []
示例#6
0
    def test_sends_session_change_when_joining_or_leaving_group(
            self, socket, message):
        socket.authenticated_userid = message["userid"]

        messages.handle_user_event(message, [socket, socket], None, None)

        reply = {
            "type": "session-change",
            "action": "group-join",
            "model": message["session_model"],
        }

        assert socket.send_json.call_args_list == [
            mock.call(reply),
            mock.call(reply),
        ]
示例#7
0
    def test_sends_session_change_when_joining_or_leaving_group(self):
        session_model = mock.Mock()
        message = {
            "type": "group-join",
            "userid": "amy",
            "group": "groupid",
            "session_model": session_model,
        }
        socket = FakeSocket("clientid")
        socket.authenticated_userid = "amy"

        messages.handle_user_event(message, [socket], None, None)

        assert socket.send_json_payloads[0] == {
            "type": "session-change",
            "action": "group-join",
            "model": session_model,
        }
示例#8
0
    def test_sends_session_change_when_joining_or_leaving_group(self):
        session_model = mock.Mock()
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
            'session_model': session_model,
        }
        socket = FakeSocket('clientid')
        socket.authenticated_userid = 'amy'

        messages.handle_user_event(message, [socket], None, None)

        assert socket.send_json_payloads[0] == {
            'type': 'session-change',
            'action': 'group-join',
            'model': session_model,
        }
示例#9
0
文件: messages_test.py 项目: ziqizh/h
    def test_sends_session_change_when_joining_or_leaving_group(self):
        session_model = mock.Mock()
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
            'session_model': session_model,
        }
        socket = FakeSocket('clientid')
        socket.authenticated_userid = 'amy'

        messages.handle_user_event(message, [socket], None, None)

        assert socket.send_json_payloads[0] == {
            'type': 'session-change',
            'action': 'group-join',
            'model': session_model,
        }
示例#10
0
    def test_sends_session_change_when_joining_or_leaving_group(self):
        session_model = mock.Mock()
        message = {
            "type": "group-join",
            "userid": "amy",
            "group": "groupid",
            "session_model": session_model,
        }
        socket = FakeSocket("clientid")
        socket.authenticated_userid = "amy"

        messages.handle_user_event(message, [socket], None, None)

        assert socket.send_json_payloads[0] == {
            "type": "session-change",
            "action": "group-join",
            "model": session_model,
        }
示例#11
0
    def test_none_when_socket_is_not_event_users(self):
        """Don't send session-change events if the event user is not the socket user."""
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
        }

        sock = FakeSocket('clientid')
        sock.request.authenticated_userid = 'bob'

        assert messages.handle_user_event(message, sock) is None
示例#12
0
    def test_none_when_socket_is_not_event_users(self, pyramid_config):
        """Don't send session-change events if the event user is not the socket user."""
        pyramid_config.testing_securitypolicy('bob')
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
        }

        sock = FakeSocket('clientid')

        assert messages.handle_user_event(message, sock) is None
示例#13
0
    def test_none_when_socket_is_not_event_users(self):
        """Don't send session-change events if the event user is not the socket user."""
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
        }

        sock = FakeSocket('clientid')
        sock.request.authenticated_userid = 'bob'

        assert messages.handle_user_event(message, sock) is None
示例#14
0
    def test_sends_session_change_when_joining_or_leaving_group(self):
        session_model = mock.Mock()
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
            'session_model': session_model,
        }

        sock = FakeSocket('clientid')
        sock.request.authenticated_userid = 'amy'

        assert messages.handle_user_event(message, sock) == {
            'type': 'session-change',
            'action': 'group-join',
            'model': session_model,
        }
示例#15
0
    def test_sends_session_change_when_joining_or_leaving_group(self, pyramid_config):
        pyramid_config.testing_securitypolicy('amy')
        session_model = mock.Mock()
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
            'session_model': session_model,
        }

        sock = FakeSocket('clientid')

        assert messages.handle_user_event(message, sock) == {
            'type': 'session-change',
            'action': 'group-join',
            'model': session_model,
        }
示例#16
0
    def test_sends_session_change_when_joining_or_leaving_group(self):
        session_model = mock.Mock()
        message = {
            'type': 'group-join',
            'userid': 'amy',
            'group': 'groupid',
            'session_model': session_model,
        }

        sock = FakeSocket('clientid')
        sock.request.authenticated_userid = 'amy'

        assert messages.handle_user_event(message, sock) == {
            'type': 'session-change',
            'action': 'group-join',
            'model': session_model,
        }