Beispiel #1
0
    def test_init_with_no_request_api(self):
        config = BrainServiceConfiguration("pannous")
        config._url = "http://test.pandora.url"

        service = DuckDuckGoService(config=config)

        self.assertIsNotNone(service)
        self.assertIsInstance(service._api, DuckDuckGoAPI)
Beispiel #2
0
    def test_init_with_no_request_api(self):
        config = BrainServiceConfiguration("pannous")
        config._url = "http://test.pandora.url"

        service = DuckDuckGoService(config=config)

        self.assertIsNotNone(service)
        self.assertIsInstance(service._api, DuckDuckGoAPI)
Beispiel #3
0
    def test_ask_question_general_exception(self):
        config = BrainServiceConfiguration("pannous")
        config._url = "http://test.pandora.url"

        service = DuckDuckGoService(config=config, api=MockDuckDuckGoAPI(response=None, throw_exception=True))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEqual("", response)
Beispiel #4
0
    def test_ask_question_general_exception(self):
        config = BrainServiceConfiguration("pannous")
        config._url = "http://test.pandora.url"

        service = DuckDuckGoService(config=config, api=MockDuckDuckGoAPI(response=None, throw_exception=True))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEquals("", response)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
0
    def test_ask_question_summary(self):
        config = BrainServiceConfiguration("pannous")
        config._url = "http://api.duckduckgo.com"

        service = DuckDuckGoService(config=config)
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "cat")
        self.assertIsNotNone(response)
        self.assertEqual("Cat A small, typically furry, carnivorous mammal", response)
Beispiel #8
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 #9
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 #10
0
    def test_ask_question_summary(self):
        config = BrainServiceConfiguration("pannous")
        config._url = "http://api.duckduckgo.com"

        service = DuckDuckGoService(config=config)
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "cat")
        self.assertIsNotNone(response)
        self.assertEqual("Cat A small, typically furry, carnivorous mammal",
                         response)
Beispiel #11
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 #12
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)
Beispiel #13
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 #14
0
    def test_init_with_no_url(self):
        config = BrainServiceConfiguration("pannous")
        config._url = None

        with self.assertRaises(Exception):
            service = DuckDuckGoService(config=config)
Beispiel #15
0
    def test_init_with_no_url(self):
        config = BrainServiceConfiguration("pannous")
        config._url = None

        with self.assertRaises(Exception):
            service = DuckDuckGoService(config=config)