test_words_api.py 672 B

123456789101112131415161718192021222324
  1. import os
  2. import pytest
  3. from pyopenagi.tools.words_api.words_api import WordsAPI
  4. from dotenv import load_dotenv, find_dotenv
  5. @pytest.fixture(scope="module")
  6. def test_rapid_api_key():
  7. load_dotenv(find_dotenv())
  8. if "RAPID_API_KEY" not in os.environ or not os.environ["RAPID_API_KEY"]:
  9. with pytest.raises(ValueError):
  10. WordsAPI()
  11. pytest.skip("Rapid api key is not set.")
  12. @pytest.mark.usefixtures("test_rapid_api_key")
  13. def test_words_api():
  14. words_api = WordsAPI()
  15. params = {
  16. "word": "look",
  17. "api_name": "typeOf",
  18. }
  19. result = words_api.run(params=params)
  20. print(result)
  21. assert isinstance(result, str)