def test_get_initial_question_initial_question_srai_match(self): bot_config = BotConfiguration() self.assertIsNotNone(bot_config) bot = MockBot(bot_config) self.assertIsNotNone(bot) client_context2 = ClientContext(TestClient(), "testid2") client_context2._bot = bot client_context2._brain = MockBrain(bot, bot.configuration.configurations[0]) client_context2._brain._response = "Y DEFAULT RESPONSE" self.assertEquals("Y DEFAULT RESPONSE", bot.get_initial_question(client_context2))
def test_get_exit_response_exit_response_srai_match(self): bot_config = BotConfiguration() self.assertIsNotNone(bot_config) bot_config.exit_response_srai = "YDEFAULTRESPONSE" bot_config.exit_response = "Default response!" client = TestClient() bot = MockBot(bot_config, client) self.assertIsNotNone(bot) client_context2 = ClientContext(TestClient(), "testid2") client_context2._bot = bot client_context2._brain = MockBrain(bot, bot.configuration.configurations[0]) client_context2._brain._response = "Y DEFAULT RESPONSE" self.assertEqual("Y DEFAULT RESPONSE", bot.get_exit_response(client_context2))
def test_format_message_with_client_context(self): client = TestClient() bot_config = BotConfiguration() bot_config._section_name = "testbot" bot = Bot(bot_config, client) brain_config = BrainConfiguration() brain_config._section_name = "testbrain" brain = Brain(bot, brain_config) client_context = ClientContext(client, "testuser") client_context._bot = bot client_context._brain = brain msg = YLogger.format_message(client_context, "Test Message") self.assertIsNotNone(msg) self.assertEqual("[testclient] [testbot] [testbrain] [testuser] - Test Message", msg)
def test_format_message_with_client_context(self): client = TestClient() bot_config = BotConfiguration() bot_config._section_name = "testbot" bot = Bot(bot_config, client) brain_config = BrainConfiguration() brain_config._section_name = "testbrain" brain = Brain(bot, brain_config) client_context = ClientContext(client, "testuser") client_context._bot = bot client_context._brain = brain msg = YLogger.format_message(client_context, "Test Message") self.assertIsNotNone(msg) self.assertEquals("[testclient] [testbot] [testbrain] [testuser] - Test Message", msg)
def test_get_default_response_default_response_srai_match(self): bot_config = BotConfiguration() self.assertIsNotNone(bot_config) bot_config.default_response_srai = "YDEFAULTRESPONSE" bot_config.default_response = "Default response!" bot = MockBot(bot_config) self.assertIsNotNone(bot) client_context2 = ClientContext(TestClient(), "testid2") client_context2._bot = bot client_context2._brain = MockBrain(bot, bot.configuration.configurations[0]) client_context2._brain._response = "Y DEFAULT RESPONSE" response = bot.get_default_response(client_context2) self.assertIsNotNone(response) self.assertEquals("Y DEFAULT RESPONSE", response)
def test_bot_with_conversation(self): client = TestClient() bot = Bot(BotConfiguration(), client) self.assertIsNotNone(bot) self.assertFalse(bot.has_conversation(self._client_context)) response = bot.ask_question(self._client_context, "hello") self.assertIsNotNone(response) self.assertTrue(bot.has_conversation(self._client_context)) response = bot.ask_question(self._client_context, "hello") self.assertIsNotNone(response) self.assertTrue(bot.has_conversation(self._client_context)) client_context2 = ClientContext(TestClient(), "testid2") client_context2._bot = bot client_context2._brain = self._client_context.bot.brain response = bot.ask_question(client_context2, "hello") self.assertIsNotNone(response) self.assertTrue(bot.has_conversation(client_context2))
def test_bot_with_conversation(self): bot = Bot(BotConfiguration()) self.assertIsNotNone(bot) self.assertFalse(bot.has_conversation(self._client_context)) response = bot.ask_question(self._client_context, "hello") self.assertIsNotNone(response) self.assertTrue(bot.has_conversation(self._client_context)) response = bot.ask_question(self._client_context, "hello") self.assertIsNotNone(response) self.assertTrue(bot.has_conversation(self._client_context)) client_context2 = ClientContext(TestClient(), "testid2") client_context2._bot = bot client_context2._brain = self._client_context.bot.brain response = bot.ask_question(client_context2, "hello") self.assertIsNotNone(response) self.assertTrue(bot.has_conversation(client_context2))