test_card.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. from base import BaseTestCase, Card, Conversation
  2. from parameterized import parameterized
  3. card = [
  4. ['nim_lang/status/1136652293510717440',
  5. 'Version 0.20.0 released',
  6. 'We are very proud to announce Nim version 0.20. This is a massive release, both literally and figuratively. It contains more than 1,000 commits and it marks our release candidate for version 1.0!',
  7. 'nim-lang.org', True],
  8. ['voidtarget/status/1094632512926605312',
  9. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too)',
  10. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too) - obsplugin.nim',
  11. 'gist.github.com', True],
  12. ['NASA/status/2061872347477418301',
  13. 'Nancy Grace Roman Space Telescope - NASA Science',
  14. 'The Nancy Grace Roman Space Telescope will settle essential questions in the areas of dark energy, exoplanets, and astrophysics.',
  15. 'science.nasa.gov', True]
  16. ]
  17. no_thumb = [
  18. ['Thom_Wolf/status/1122466524860702729',
  19. 'GitHub - facebookresearch/XLM: PyTorch original implementation of Cross-lingual Language Model',
  20. 'PyTorch original implementation of Cross-lingual Language Model Pretraining.',
  21. 'github.com'],
  22. ['brent_p/status/1088857328680488961',
  23. 'GitHub - brentp/hts-nim: nim wrapper for htslib for parsing genomics data files',
  24. '',
  25. 'github.com'],
  26. ['voidtarget/status/1133028231672582145',
  27. 'sinkingsugar/nimqt-example',
  28. 'A sample of a Qt app written using mostly nim. Contribute to sinkingsugar/nimqt-example development by creating an account on GitHub.',
  29. 'github.com']
  30. ]
  31. playable = [
  32. ['NASA/status/2047048645845897398',
  33. 'NASA\'s Artemis II News Conference with Moon Astronauts',
  34. 'Live from NASA\'s Johnson Space Center in Houston',
  35. 'youtube.com']
  36. ]
  37. class CardTest(BaseTestCase):
  38. @parameterized.expand(card)
  39. def test_card(self, tweet, title, description, destination, large):
  40. self.open_nitter(tweet)
  41. c = Card(Conversation.main + " ")
  42. self.assert_text(title, c.title)
  43. self.assert_text(destination, c.destination)
  44. self.assertIn('/pic/', self.get_image_url(c.image + ' img'))
  45. if len(description) > 0:
  46. self.assert_text(description, c.description)
  47. if large:
  48. self.assert_element_visible('.card.large')
  49. else:
  50. self.assert_element_not_visible('.card.large')
  51. @parameterized.expand(no_thumb)
  52. def test_card_no_thumb(self, tweet, title, description, destination):
  53. self.open_nitter(tweet)
  54. c = Card(Conversation.main + " ")
  55. self.assert_text(title, c.title)
  56. self.assert_text(destination, c.destination)
  57. if len(description) > 0:
  58. self.assert_text(description, c.description)
  59. @parameterized.expand(playable, skip_on_empty=True)
  60. def test_card_playable(self, tweet, title, description, destination):
  61. self.open_nitter(tweet)
  62. c = Card(Conversation.main + " ")
  63. self.assert_text(title, c.title)
  64. self.assert_text(destination, c.destination)
  65. self.assertIn('/pic/', self.get_image_url(c.image + ' img'))
  66. self.assert_element_visible('.card-overlay')
  67. if len(description) > 0:
  68. self.assert_text(description, c.description)