test_vboo_info_bot_functions.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. assert isinstance(response['content_html'], str), "Content html should be a string"
  30. assert isinstance(response['language'], str), "Language should be a string"
  31. assert isinstance(response['rating'], int), "Rating should be an integer"
  32. @pytest.mark.vcr()
  33. def test_article_info_two(api_wrapper, article_keys):
  34. """Test article info"""
  35. article_id = 2862982
  36. response = Article(api_wrapper).info(article_id)
  37. assert isinstance(response, dict), "The resonse should be a dict"
  38. assert set(article_keys).issubset(response.keys()), "All keys should be in the response"
  39. assert isinstance(response['article_id'], int), "Article id should be an integer"
  40. assert isinstance(response['article_title'], str), "Article title should be a str"
  41. assert response['newspaper_id'] is None, "Newspaper id should be none"
  42. assert response['newspaper_name'] is None, "Newspaper name should be none"
  43. assert isinstance(response['author_name'], str), "Author name should be a string"
  44. assert isinstance(response['author_id'], int), "Author id should be an integer"
  45. assert isinstance(response['region_name'], str), "Region name should be a string"
  46. assert isinstance(response['region_id'], int), "Region id should be an integer"
  47. assert isinstance(response['content_text'], str), "Content text should be a string"
  48. assert isinstance(response['content_html'], str), "Content html should be a string"
  49. assert isinstance(response['language'], str), "Language should be a string"
  50. assert isinstance(response['content_html'], str), "Content html should be a string"
  51. assert isinstance(response['language'], str), "Language should be a string"
  52. assert isinstance(response['rating'], int), "Rating should be an integer"