Exemplo n.º 1
0
    def test_regex1(self):
        text = rf"{smart} {option_add} {option_regex} \bСлов[оауе]*\b || Ответ "
        data = input_data(OwnerAndBotChatData.peer_id, text,
                          OwnerAndBotChatData.owner_id)
        EventHandler(data).process()
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "Слово",
                           "SMART_REPLY_SENT",
                           bot_response="Ответ")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "Слова",
                           "SMART_REPLY_SENT",
                           bot_response="Ответ")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "нет Слов",
                           "SMART_REPLY_SENT",
                           bot_response="Ответ")

        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "Словесный",
                           "SMART_NOT_TRIGGER")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "слово",
                           "SMART_NOT_TRIGGER")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "нет слов",
                           "SMART_NOT_TRIGGER")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "нет СЛОВ",
                           "SMART_NOT_TRIGGER")
Exemplo n.º 2
0
    def test_regex2(self):
        text = rf"{smart} {option_add} {option_regex} \bОлег[ауе] || Я знаю Олега! "
        data = input_data(OwnerAndBotChatData.peer_id, text,
                          OwnerAndBotChatData.owner_id)
        EventHandler(data).process()
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "дай Олегу печеньку",
                           "SMART_REPLY_SENT",
                           bot_response="Я знаю Олега!")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "Олега не было",
                           "SMART_REPLY_SENT",
                           bot_response="Я знаю Олега!")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "об Олеге",
                           "SMART_REPLY_SENT",
                           bot_response="Я знаю Олега!")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "Олегу",
                           "SMART_REPLY_SENT",
                           bot_response="Я знаю Олега!")

        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "дай олегу печеньку",
                           "SMART_NOT_TRIGGER")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "Олег",
                           "SMART_NOT_TRIGGER")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "Олежка дурачок",
                           "SMART_NOT_TRIGGER")
Exemplo n.º 3
0
 def create_input_message_instance(self,
                                   input_text,
                                   peer_id=OwnerAndBotChatData.peer_id,
                                   from_id=OwnerAndBotChatData.owner_id):
     data = input_data(peer_id, input_text, from_id)
     self.event_object = EventHandler(data)
     input_message_object = InputMessage(self.event_object.event_dict)
     return input_message_object
Exemplo n.º 4
0
 def test_vk_secret_wrong(self):
     data = input_data(self.peer_id, '/reg on', self.owner_id,
                       "12345678910")
     response = self.client.post(self.url,
                                 data,
                                 content_type="application/json")
     self.assertEqual(response.status_code, 403)
     self.assertEqual(response.content, b'AUTHENTICATION ERROR')
Exemplo n.º 5
0
 def test_vk_secret_right(self):
     try:
         celery_check = settings.CELERY_BROKER_URL
         data = input_data(self.peer_id, 'some text', self.owner_id,
                           VK_SECRET)
         response = self.client.post(self.url,
                                     data,
                                     content_type="application/json")
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.content, b'ok')
     except AttributeError:
         pass
Exemplo n.º 6
0
    def test_no_regex(self):
        text = f"{smart} {option_add} Привет, кукушонок! || Сам привет!"
        data = input_data(OwnerAndBotChatData.peer_id, text,
                          OwnerAndBotChatData.owner_id)
        EventHandler(data).process()
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "Привет, кукушонок!",
                           "SMART_REPLY_SENT",
                           bot_response="Сам привет!")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "привет, кукушонок!",
                           "SMART_REPLY_SENT",
                           bot_response="Сам привет!")

        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "Привет!",
                           "SMART_NOT_TRIGGER")
Exemplo n.º 7
0
    def test(self):
        text = f'{smart} add regex' + r' \bкирил[ауе]?\b || olala'
        data = input_data(OwnerAndBotChatData.peer_id, text,
                          OwnerAndBotChatData.owner_id)
        EventHandler(data).process()
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "вдупляй,кирил",
                           "SMART_REPLY_SENT",
                           bot_response="olala")
        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id,
                           "у кирила",
                           "SMART_REPLY_SENT",
                           bot_response="olala")

        self.core_pipeline(OwnerAndBotChatData.peer_id,
                           OwnerAndBotChatData.owner_id, "кириллица",
                           "SMART_NOT_TRIGGER")
 def pipeline_process(self, from_id):
     text = "message"
     data = input_data(OwnerAndBotChatData.peer_id, text, from_id)
     event_object = EventHandler(data)
     self.input_message_object = InputMessage(event_object.event_dict)
     return EventHandler(data).process()