def test_message_handling(self): event = Mock() event.type = self.ROW_EVENT['type'] event.message = Mock() event.message.from_id = self.ROW_EVENT['object']['message']['from_id'] event.message.text = self.ROW_EVENT['object']['message']['text'] get_message_response_mock = Mock() with patch('chatbot.bot.VkBotEventType') as VkBotEventType, \ patch('chatbot.bot.ChatBotDataBase'), \ patch('chatbot.bot.logging'): VkBotEventType.MESSAGE_NEW = 'message_new' bot = ChatBot('', '') bot.get_message_response = get_message_response_mock bot.message_handling(event) get_message_response_mock.assert_called_once_with(event=event)
def test_run(self): long_poll_listen_mock = Mock() long_poll_listen_mock.listen = self.listen message_handling_mock = Mock() with patch('chatbot.bot.VkApi'), \ patch('chatbot.bot.VkBotLongPoll', return_value=long_poll_listen_mock), \ patch('chatbot.bot.logging'): bot = ChatBot('', '') bot.message_handling = message_handling_mock bot.run() message_handling_mock.assert_called_once()