예제 #1
0
    def test_ask_question_with_exception(self):

        config = BrainServiceConfiguration("pannous")
        config._url = "http://test.pandora.url"

        service = PannousService(config=config, api=MockPannousAPI(response="Some wierd error", throw_exception=True))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEquals("", response)
예제 #2
0
    def test_ask_question(self):

        config = BrainServiceConfiguration("pannous")
        config._url = "http://test.pandora.url"

        service = PannousService(config=config, api=MockPannousAPI(response="Test pannous response"))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEquals("Test pannous response", response)
예제 #3
0
    def test_ask_question_no_url(self):

        config = BrainServiceConfiguration("pannous")

        with self.assertRaises(Exception) as raised:
            service = PannousService(config=config, api=MockPannousAPI(response="Test pannous response"))
            self.assertIsNotNone(service)

            response = service.ask_question(self._client_context, "what is a cat")
            self.assertEquals("", response)

        self.assertEqual(raised.exception.args[0], "Undefined url parameter")
예제 #4
0
    def test_ask_question_no_license_key(self):

        self.bot = TestBot()
        self.bot.license_keys = LicenseKeys()

        config = BrainServiceConfiguration("pannous")
        config._url = "http://test.pandora.url"

        service = PannousService(config=config, api=MockPannousAPI(response="Test pannous response"))
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "what is a cat")
        self.assertEquals("", response)