test_vboo_info_bot_functions.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. """Wrapper test"""
  2. from rival_regions_wrapper.api_wrapper import Article
  3. import pytest
  4. from vboo_info_bot import functions
  5. @pytest.fixture
  6. def article_keys():
  7. """Standard key fro article"""
  8. return ['article_id', 'article_title', 'newspaper_id', 'newspaper_name', \
  9. 'author_name', 'author_id', 'region_name', 'region_id', 'content_text', 'content_html', \
  10. 'language']
  11. @pytest.mark.vcr()
  12. def test_article_info_one(api_wrapper, article_keys):
  13. """Test article info"""
  14. article_id = 2708696
  15. response = Article(api_wrapper).info(article_id)
  16. assert isinstance(response, dict), "The resonse should be a dict"
  17. assert set(article_keys).issubset(response.keys()), "All keys should be in the response"
  18. assert isinstance(response['article_id'], int), "Article id should be an integer"
  19. assert isinstance(response['article_title'], str), "Article title should be a str"
  20. assert isinstance(response['newspaper_id'], int), "Newspaper id should be an integer"
  21. assert isinstance(response['newspaper_name'], str), "Newspaper name should be a string"
  22. assert isinstance(response['author_name'], str), "Author name should be a string"
  23. assert isinstance(response['author_id'], int), "Author id should be an integer"
  24. assert isinstance(response['region_name'], str), "Region name should be a string"
  25. assert isinstance(response['region_id'], int), "Region id should be an integer"
  26. assert isinstance(response['content_text'], str), "Content text should be a string"
  27. assert isinstance(response['content_html'], str), "Content html should be a string"
  28. assert isinstance(response['language'], str), "Language should be a string"
  29. @pytest.mark.vcr()
  30. def test_article_info_two(api_wrapper, article_keys):
  31. """Test article info"""
  32. article_id = 2862982
  33. response = Article(api_wrapper).info(article_id)
  34. assert isinstance(response, dict), "The resonse should be a dict"
  35. assert set(article_keys).issubset(response.keys()), "All keys should be in the response"
  36. assert isinstance(response['article_id'], int), "Article id should be an integer"
  37. assert isinstance(response['article_title'], str), "Article title should be a str"
  38. assert isinstance(response['newspaper_id'], int), "Newspaper id should be an integer"
  39. assert isinstance(response['newspaper_name'], str), "Newspaper name should be a string"
  40. assert isinstance(response['author_name'], str), "Author name should be a string"
  41. assert isinstance(response['author_id'], int), "Author id should be an integer"
  42. assert isinstance(response['region_name'], str), "Region name should be a string"
  43. assert isinstance(response['region_id'], int), "Region id should be an integer"
  44. assert isinstance(response['content_text'], str), "Content text should be a string"
  45. assert isinstance(response['content_html'], str), "Content html should be a string"
  46. assert isinstance(response['language'], str), "Language should be a string"