def bot_reply(self): if self.comment_type == 'Bot' and self.communication_type == 'Chat': reply = BotReply().get_reply(self.content) if reply: frappe.get_doc({ "doctype": "Communication", "comment_type": "Bot", "communication_type": "Bot", "content": cstr(reply), "reference_doctype": self.reference_doctype, "reference_name": self.reference_name }).insert() frappe.local.flags.commit = True
def test_list(self): reply = BotReply().get_reply('list users') self.assertTrue('(#Form/User/[email protected])' in reply)
def test_how_many(self): reply = BotReply().get_reply('how many users') self.assertTrue(int(reply) > 1)
def test_not_found(self): reply = BotReply().get_reply('find yoyo in doctypes') self.assertTrue('Could not find' in reply)
def test_find(self): reply = BotReply().get_reply('find user in doctypes') self.assertTrue('[User](#Form/DocType/User)' in reply)
def test_open_notifications(self): reply = BotReply().get_reply('whatsup') self.assertTrue('your attention' in reply)
def test_hello(self): reply = BotReply().get_reply('hello') self.assertEqual(reply, 'Hello Administrator')
def test_list(self): reply = BotReply().get_reply('list users') self.assertTrue('[[email protected]]' in reply)