test_wolfram_alpha.py 688 B

12345678910111213141516171819202122
  1. import os
  2. import pytest
  3. from pyopenagi.tools.wolfram.wolfram_alpha import WolframAlpha
  4. from dotenv import load_dotenv, find_dotenv
  5. @pytest.fixture(scope="module")
  6. def test_wolfram_alpha_id():
  7. load_dotenv(find_dotenv())
  8. if "WOLFRAM_ALPHA_APPID" not in os.environ or not os.environ["WOLFRAM_ALPHA_APPID"]:
  9. with pytest.raises(ValueError):
  10. WolframAlpha()
  11. pytest.skip("WolframAlpha app id is not set.")
  12. else:
  13. return True
  14. @pytest.mark.usefixtures("test_wolfram_alpha_id")
  15. def test_wolfram_alpha():
  16. wolfram_alpha = WolframAlpha()
  17. query = "What is the square root of 144?"
  18. result = wolfram_alpha.run(query)
  19. assert "12" in result