コード例 #1
0
ファイル: test_markov.py プロジェクト: motsu35/markov-bot
def test_remove_messages(mock_db, mock_bot, mock_model, message):
    mock_bot.get_chat_administrators.return_value = [message]
    chat_id = str(message.chat.id)
    markov.remove_messages(message)
    assert mock_db.delete.called_once_with(chat_id=chat_id)
    assert mock_model.cache_clear.called
    assert mock_bot.reply_to.called
コード例 #2
0
def test_remove_messages_ask_confirm(mock_markup, mock_db, mock_bot,
                                     mock_model, message):
    message.text = '/remove'
    mock_bot.get_chat_administrators.return_value = [message]
    markov.remove_messages(message)
    assert mock_markup.add.called_once_with('yes', 'no')
    assert mock_bot.reply_to.called_once_with(
        message,
        'this operation will delete all data, are you sure?',
        reply_markup=mock_markup)
    assert mock_bot.register_next_step_handler.called is True
コード例 #3
0
def test_remove_messages_no_permission(mock_db, mock_bot, mock_model, message):
    mock_bot.get_chat_administrators.return_value = []
    markov.remove_messages(message)
    assert mock_db.delete.called is False
    assert mock_model.cache_clear.called is False
    assert mock_bot.reply_to.called_once_with(message, 'u r not an admin 🤔')
コード例 #4
0
def test_remove_messages_cancel(mock_db, mock_bot, mock_model, message):
    message.text = 'no'
    mock_bot.get_chat_administrators.return_value = [message]
    markov.remove_messages(message)
    assert mock_db.delete.called is False
    assert mock_model.cache_clear.called is False