/test/integration/programy/services/test_duckduckgo.py

https://github.com/keiffster/program-y · Python · 31 lines · 21 code · 10 blank · 0 comment · 0 complexity · d778bc6d12984409346b298185e84ec9 MD5 · raw file

  1. import unittest
  2. import os
  3. from programy.utils.license.keys import LicenseKeys
  4. from programy.services.duckduckgo import DuckDuckGoService
  5. from programy.services.service import BrainServiceConfiguration
  6. class TestBot:
  7. def __init__(self):
  8. self.license_keys = None
  9. class DuckDuckGoServiceTests(unittest.TestCase):
  10. def setUp(self):
  11. self.bot = TestBot()
  12. self.bot.license_keys = LicenseKeys()
  13. self.bot.license_keys.load_license_key_file(os.path.dirname(__file__)+ os.sep + "test.keys")
  14. def test_ask_question_summary(self):
  15. config = BrainServiceConfiguration("pannous")
  16. config._url = "http://api.duckduckgo.com"
  17. service = DuckDuckGoService(config=config)
  18. self.assertIsNotNone(service)
  19. response = service.ask_question(self.bot, "testid", "cat")
  20. self.assertIsNotNone(response)
  21. self.assertEqual("Cat A small, typically furry, carnivorous mammal", response)