예제 #1
0
    def test_ask_question_summary(self):
        service = WikipediaService()
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "SUMMARY cat")
        self.assertIsNotNone(response)
        self.assertEqual("The domestic cat (Felis silvestris catus or Felis catus) is a small, typically furry, carnivorous mammal.", response)
예제 #2
0
    def test_ask_question_search(self):
        service = WikipediaService()
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "SEARCH cat")
        self.assertIsNotNone(response)
        self.assertTrue(response.startswith("Cat"))
예제 #3
0
    def test_ask_question_pageerror_exception(self):
        service = WikipediaService(api=MockWikipediaAPI(
            response=None, throw_exception=MockWikipediaAPI.PAGEERROR))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEqual("", response)
예제 #4
0
    def test_ask_question_general_exception(self):
        service = WikipediaService(api=MockWikipediaAPI(
            response=None, throw_exception=MockWikipediaAPI.GENERALEXCEPTION))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEqual("", response)
예제 #5
0
    def test_ask_question(self):
        service = WikipediaService(api=MockWikipediaAPI(
            response="Test Wikipedia response"))
        self.assertIsNotNone(service)

        response = service.ask_question(self.bot, "testid", "what is a cat")
        self.assertEquals("Test Wikipedia response", response)
예제 #6
0
    def test_ask_question_disambiguous(self):
        service = WikipediaService(api=MockWikipediaAPI(
            response=None,
            throw_exception=MockWikipediaAPI.DISAMBIGUATIONERROR))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEqual("", response)
예제 #7
0
    def test_ask_question(self):
        service = WikipediaService(api=MockWikipediaAPI(
            response="Test Wikipedia response"))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context,
                                        "SUMMARY what is a cat")
        self.assertEqual("Test Wikipedia response", response)
예제 #8
0
    def test_ask_question_general_exception(self):
        service = WikipediaService(api=MockWikipediaAPI(response=None, throw_exception=MockWikipediaAPI.GENERALEXCEPTION))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEquals("", response)
예제 #9
0
    def test_ask_question_pageerror_exception(self):
        service = WikipediaService(api=MockWikipediaAPI(response=None, throw_exception=MockWikipediaAPI.PAGEERROR))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEquals("", response)
예제 #10
0
    def test_ask_question_disambiguous(self):
        service = WikipediaService(api=MockWikipediaAPI(response=None, throw_exception=MockWikipediaAPI.DISAMBIGUATIONERROR))
        self.assertIsNotNone(service)

        response = service.ask_question(self._client_context, "what is a cat")
        self.assertEquals("", response)
예제 #11
0
    def test_ask_question(self):
        service = WikipediaService(api=MockWikipediaAPI(response="Test Wikipedia response"))
        self.assertIsNotNone(service)

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