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()
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 == []
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 == []
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), ]
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, }
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, }
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
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
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, }
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, }