Exemplo n.º 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.bot, "testid", "what is a cat")
        self.assertEquals("Test pandora response", response)
Exemplo n.º 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.bot, "testid", "what is a cat")
        self.assertEquals("", response)
Exemplo n.º 3
0
    def test_ask_question(self):
        config = BrainServiceConfiguration("rest")
        config._host = "127.0.0.1"
        config._method = "GET"

        service = GenericRESTService(config=config, api=MockRestAPI())
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "what is a cat")
        self.assertEquals("Test REST response", response)
Exemplo n.º 4
0
    def test_ask_question(self):

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

        service = PannousService(config=config, api=MockPannousAPI())
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "what is a cat")
        self.assertEquals("Test pannous response", response)
Exemplo n.º 5
0
    def test_ask_question_no_botid(self):

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

        config = BrainServiceConfiguration("pandora")
        config.set_parameter("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("", response)
Exemplo n.º 6
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)
Exemplo n.º 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")