Example #1
0
    def test_answer_if_running(self):
        quest = MagicMock()
        quest.assess_answer.return_value = []
        answer_text = 'abc'

        bot_logic = BotLogic(quest)
        bot_logic.is_started = True
        bot_logic.answer(answer_text)

        self.assertEqual(bot_logic.is_started, True)
        quest.assess_answer.assert_called_once()
Example #2
0
    def test_handle_message_answer(self):
        quest = MagicMock()
        update = MagicMock()
        update.message.text = 'abc'
        context = MagicMock()

        bot_logic = BotLogic(quest)
        bot_logic.answer = MagicMock(return_value=[])
        bot_logic.handle_message(update, context)

        bot_logic.answer.assert_called_once()
Example #3
0
    def test_answer_if_not_running(self):
        quest = MagicMock()
        quest.assess_answer.return_value = []
        answer_text = 'abc'

        bot_logic = BotLogic(quest)
        bot_logic.is_started = False
        messages_list = bot_logic.answer(answer_text)

        self.assertEqual(bot_logic.is_started, False)
        quest.assess_answer.assert_not_called()
        self.assertEqual(messages_list[0].text,
                         bot_logic.messages['bot_not_started'])
        self.assertEqual(len(messages_list), 1)