def test_handle_user_event_none_when_socket_is_not_event_users(): """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 streamer.handle_user_event(message, sock) is None
def test_handle_user_event_sends_session_change_when_joining_or_leaving_group(): session_model = Mock() message = { 'type': 'group-join', 'userid': 'amy', 'group': 'groupid', 'session_model': session_model, } sock = FakeSocket('clientid') sock.request.authenticated_userid = 'amy' assert streamer.handle_user_event(message, sock) == { 'type': 'session-change', 'action': 'group-join', 'model': session_model, }