예제 #1
0
def test_start_disco(mocker, mocked_not_started_poll):
    mocked_admin = mocker.patch('handlers.decorators.is_admin')
    mocked_send_to_usr = mocker.patch(
        'handlers.commands.disco.send_msg_to_user')

    mocked_admin.return_value = True
    mocked_not_started_poll.storage.check_for_unfinished_poll.return_value = True

    disco.start_disco(Mock(), mocked_not_started_poll, {})
    assert mocked_send_to_usr.called
예제 #2
0
def test_start_disco_without_csv(mocker, mocked_not_started_poll):
    mocked_admin = mocker.patch('handlers.decorators.is_admin')
    mocked_send_to_usr = mocker.patch(
        'handlers.commands.disco.send_msg_to_user')
    mocked_parse_disco = mocker.patch(
        'handlers.commands.disco.parse_disco_args')

    # Default settings to pass trough decorators.
    mocked_admin.return_value = True
    mocked_not_started_poll.storage.check_for_unfinished_poll.return_value = False
    mocked_parse_disco.return_value = False
    disco.start_disco(Mock(), mocked_not_started_poll, {})
    assert mocked_send_to_usr.called
예제 #3
0
def handle_commands(client: WebClient, poll: Poll, request_form: dict) -> None:
    """
    Function that will handle all the commands that is going to be sent to the bot.
    """

    command = request_form.get('command')

    if command == '/disco':
        if command_args := request_form.get('text'):
            poll.number_of_songs = parse_disco_args(poll.number_of_songs,
                                                    command_args)
            start_disco(client, poll, request_form)
        else:
            start_disco(client, poll, request_form)
예제 #4
0
def test_start_disco_with_songs(mocker, mocked_not_started_poll):
    mocked_admin = mocker.patch('handlers.decorators.is_admin')
    mocked_parse_disco = mocker.patch(
        'handlers.commands.disco.parse_disco_args')
    mocked_parse_csv = mocker.patch(
        'handlers.commands.disco.parse_csv_with_songs')
    mocked_prepare_songs = mocker.patch(
        'handlers.commands.disco.prepare_songs_for_poll')

    # Default settings to pass trough decorators.
    mocked_admin.return_value = True
    mocked_not_started_poll.storage.check_for_unfinished_poll.return_value = False
    mocked_parse_disco.return_value = True
    mocked_parse_csv.return_value = True
    disco.start_disco(Mock(), mocked_not_started_poll, {})
    assert mocked_prepare_songs.called
예제 #5
0
def handle_commands(client: WebClient, poll: Poll, request_form: dict) -> None:
    """
    Function, that will handle all the commands that is going to be sent to the bot.
    """
    command = request_form.get('command')

    if command == '/disco':
        start_disco(client, poll, request_form)
    elif command == '/lightsoff':
        start_lightsoff(client, poll, request_form)
    elif command == '/poptop':
        start_poptop(client, poll, request_form)
    elif command == '/top':
        start_top(client, poll, request_form)
    elif command == '/poll_status':
        start_poll_status(client, poll, request_form)
    elif command == '/settings':
        start_settings(client, poll, request_form)
    elif command == '/drop':
        start_drop(client, poll, request_form)
    elif command == '/resume':
        start_resume(client, poll, request_form)