Beispiel #1
0
    def test_ask_question(self):

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

        service = PandoraService(config=config, api=MockPandoraAPI(response="Test pandora response"))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEquals("Test pandora response", response)
Beispiel #2
0
    def test_ask_question_with_exception(self):

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

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

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

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

        service = PandoraService(
            config=config,
            api=MockPandoraAPI(response="Test pandora response"))
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "what is a cat")
        self.assertEquals("Test pandora response", response)
Beispiel #4
0
    def test_ask_question_no_url(self):

        config = BrainServiceConfiguration("pandora")

        with self.assertRaises(Exception) as raised:
            service = PandoraService(config=config, api=MockPandoraAPI(response="Test pandora 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")
Beispiel #5
0
    def test_ask_question_with_exception(self):

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

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

        response = service.ask_question(self.bot, "testid", "what is a cat")
        self.assertEquals("", response)
Beispiel #6
0
    def test_ask_question_no_botid(self):

        self._client_context.client.license_keys._keys.clear()

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

        service = PandoraService(
            config=config,
            api=MockPandoraAPI(response="Test pandora response"))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEqual("", response)
Beispiel #7
0
    def test_ask_question_no_url(self):

        config = BrainServiceConfiguration("pandora")

        with self.assertRaises(Exception) as raised:
            service = PandoraService(
                config=config,
                api=MockPandoraAPI(response="Test pandora response"))
            self.assertIsNotNone(service)

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

        self.assertEqual(raised.exception.args[0], "Undefined url parameter")