示例#1
0
async def test_no_caption_no_tip(mocker: MockerFixture):
    # given
    message_mock = mock_message('/ko')
    manager_mock = mock_manager(KOLINE_DEFAULT_PARSED)
    full_view_mock = mocker.patch('pewpewbot.views.sector_default_ko_message', return_value='mocked_view')

    # when
    await send_ko(message_mock, manager_mock, **{'command_name': 'ko'})

    # then
    full_view_mock.assert_called_once_with(manager_mock.state.koline.sectors[0])
    message_mock.reply.assert_called_once_with('mocked_view\n', parse_mode='Markdown')
示例#2
0
async def test_no_caption_with_tip(mocker: MockerFixture):
    # given
    message_mock = mock_message('/ko')
    manager_mock = mock_manager()
    pin_message_mock = get_pin_message_to_mock_tip_for_manager_with_ko(manager=manager_mock)
    future_koline = Future()
    future_koline.set_result(manager_mock.state.koline)
    manager_mock.get_or_load_and_parse_koline = Mock(return_value=future_koline)
    full_view_mock = mocker.patch('pewpewbot.views.sector_with_tips_ko_message', return_value='mocked_view')

    # when
    await process_tip(pin_message_mock, manager_mock, **{'command_name': 'tip'})
    await send_ko(message_mock, manager_mock, **{'command_name': 'ko'})

    # then
    full_view_mock.assert_called_once_with(manager_mock.state.koline.sectors[0], manager_mock.state.tip[0])
    message_mock.reply.assert_called_once_with('mocked_view\n', parse_mode='Markdown')
示例#3
0
def mock_default(old_status: Status = None, new_status: Status = None):
    if not old_status:
        old_status = mock_status()
    message_mock = mock_message(DR_CODE)
    manager_mock = mock_manager(game_status=old_status)
    manager_mock.state.type_on = True
    code_verdict = CodeVerdict(55)
    future_status = Future()
    if not new_status:
        new_status = old_status
    future_status.set_result(new_status)
    manager_mock.http_client.post_code = Mock()
    manager_mock.http_client.status = Mock(return_value=future_status)
    verdict_message = code_verdict_view(code_verdict.value, DR_CODE)
    expected_caption = code_update_view(verdict_message, SECTOR_NAME_DEFAULT,
                                        TM_DEFAULT, LABEL_UP_DEFAULT,
                                        KO_DEFAULT)
    return message_mock, manager_mock, code_verdict, expected_caption
示例#4
0
async def test_no_caption_no_tip_multi_sector(mocker: MockerFixture):
    # given
    message_mock = mock_message('/ko')
    manager_mock = mock_manager(parse_koline_from_string(KOLINE_MULTISECTOR_BONUS_CODE_UP))
    future_koline = Future()
    future_koline.set_result(manager_mock.state.koline)
    manager_mock.get_or_load_and_parse_koline = Mock(return_value=future_koline)
    full_view_mock = mocker.patch('pewpewbot.views.sector_default_ko_message', return_value='mocked_view')

    # when
    await send_ko(message_mock, manager_mock, **{'command_name': 'ko'})

    # then
    full_view_mock.has_calls([
        call(manager_mock.state.koline.sectors[0]),
        call(manager_mock.state.koline.sectors[1]),
    ])
    message_mock.reply.assert_called_once_with('mocked_view\nmocked_view\n', parse_mode='Markdown')