Exemplo n.º 1
0
 def test_message_response(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']
     send_message_mock = Mock()
     with patch('chatbot.bot.VkBotEventType'), patch('chatbot.bot.logging'):
         bot = ChatBot('', '')
         bot.send_message = send_message_mock
         bot.get_message_response(event=event)
         send_message_mock.assert_called_once_with(message_text='Привет!',
                                                   user_id=8023886)
Exemplo n.º 2
0
 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)