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)
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"))
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)
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)
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)
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)
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)
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)
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)
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)
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)