/dialogue-engine/test/integration/programy/services/test_duckduckgo.py

https://github.com/cotobadesign/cotoba-agent-oss · Python · 46 lines · 32 code · 10 blank · 4 comment · 0 complexity · 89fef68ed08ac82df207c081932cdece MD5 · raw file

  1. """
  2. Copyright (c) 2020 COTOBA DESIGN, Inc.
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  4. documentation files (the "Software"), to deal in the Software without restriction, including without limitation
  5. the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
  6. and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  7. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  8. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  9. THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  11. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  12. """
  13. import unittest
  14. import os
  15. from programy.utils.license.keys import LicenseKeys
  16. from programy.services.duckduckgo import DuckDuckGoService
  17. from programy.services.service import BrainServiceConfiguration
  18. class TestBot:
  19. def __init__(self):
  20. self.license_keys = None
  21. class DuckDuckGoServiceTests(unittest.TestCase):
  22. def setUp(self):
  23. self.bot = TestBot()
  24. self.bot.license_keys = LicenseKeys()
  25. self.bot.license_keys.load_license_key_file(os.path.dirname(__file__) + os.sep + "test.keys")
  26. def test_ask_question_summary(self):
  27. config = BrainServiceConfiguration("pannous")
  28. config._url = "http://api.duckduckgo.com"
  29. service = DuckDuckGoService(config=config)
  30. self.assertIsNotNone(service)
  31. response = service.ask_question(self.bot, "cat")
  32. self.assertIsNotNone(response)
  33. self.assertEqual("Cat A small, typically furry, carnivorous mammal", response)