Пример #1
0
    def test_start_poptop_without_song_upload(self, mock_send_msg, mock_sort,
                                              mock_check_args, mock_admin):
        poll = Mock()
        request_form = Mock()
        client = Mock()

        mock_admin.return_value = True
        poll.is_started = True
        poll.is_music_upload = False

        mock_check_args.return_value = 1
        mock_sort.return_value = [{
            'title': 'TestTitle',
            'artist': 'TestArtist',
            'link': None,
            'voted_users': []
        }]

        start_poptop(client, poll, request_form)
        assert mock_send_msg.called
Пример #2
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)
def test_start_poptop_with_song_upload(mocker, mocked_started_poll):
    mocked_admin = mocker.patch('handlers.decorators.is_admin')
    mocked_check_args = mocker.patch(
        'handlers.commands.poptop.check_poptop_argument')
    mocked_sort_songs = mocker.patch('handlers.commands.poptop.sort_songs')
    mocked_upload_songs = mocker.patch('handlers.commands.poptop.upload_song')

    request_form = Mock()
    client = Mock()

    mocked_admin.return_value = True
    mocked_check_args.return_value = 1

    mocked_sort_songs.return_value = [{
        'title': 'TestTitle',
        'artist': 'TestArtist',
        'link': None,
        'voted_users': []
    }]

    start_poptop(client, mocked_started_poll, request_form)
    assert mocked_upload_songs.called