test_card.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. from base import BaseTestCase, Card, Conversation
  2. from parameterized import parameterized
  3. card = [
  4. ['Thom_Wolf/status/1122466524860702729',
  5. 'pytorch/fairseq',
  6. 'Facebook AI Research Sequence-to-Sequence Toolkit written in Python. - GitHub - pytorch/fairseq: Facebook AI Research Sequence-to-Sequence Toolkit written in Python.',
  7. 'github.com', True],
  8. ['nim_lang/status/1136652293510717440',
  9. 'Version 0.20.0 released',
  10. '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!',
  11. 'nim-lang.org', False],
  12. ['voidtarget/status/1094632512926605312',
  13. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too)',
  14. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too) - obsplugin.nim',
  15. 'gist.github.com', True],
  16. ['FluentAI/status/1116417904831029248',
  17. 'Amazon’s Alexa isn’t just AI — thousands of humans are listening',
  18. 'One of the only ways to improve Alexa is to have human beings check it for errors',
  19. 'theverge.com', True]
  20. ]
  21. no_thumb = [
  22. ['brent_p/status/1088857328680488961',
  23. 'Hts Nim Sugar',
  24. 'hts-nim is a library that allows one to use htslib via the nim programming language. Nim is a garbage-collected language that compiles to C and often has similar performance. I have become very...',
  25. 'brentp.github.io'],
  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. ['mobile_test/status/490378953744318464',
  31. 'Nantasket Beach',
  32. 'Explore this photo titled Nantasket Beach by Ben Sandofsky (@sandofsky) on 500px',
  33. '500px.com'],
  34. ['nim_lang/status/1082989146040340480',
  35. 'Nim in 2018: A short recap',
  36. 'Posted in r/programming by u/miran1',
  37. 'reddit.com']
  38. ]
  39. playable = [
  40. ['nim_lang/status/1118234460904919042',
  41. 'Nim development blog 2019-03',
  42. 'Arne (aka Krux02)* debugging: * improved nim-gdb, $ works, framefilter * alias for --debugger:native: -g* bugs: * forwarding of .pure. * sizeof union* fe...',
  43. 'youtube.com'],
  44. ['nim_lang/status/1121090879823986688',
  45. 'Nim - First natively compiled language w/ hot code-reloading at...',
  46. '#nim #c++ #ACCUConfNim is a statically typed systems and applications programming language which offers perhaps some of the most powerful metaprogramming cap...',
  47. 'youtube.com']
  48. ]
  49. # promo = [
  50. # ['BangOlufsen/status/1145698701517754368',
  51. # 'Upgrade your journey', '',
  52. # 'www.bang-olufsen.com'],
  53. # ['BangOlufsen/status/1154934429900406784',
  54. # 'Learn more about Beosound Shape', '',
  55. # 'www.bang-olufsen.com']
  56. # ]
  57. class CardTest(BaseTestCase):
  58. @parameterized.expand(card)
  59. def test_card(self, tweet, title, description, destination, large):
  60. self.open_nitter(tweet)
  61. c = Card(Conversation.main + " ")
  62. self.assert_text(title, c.title)
  63. self.assert_text(destination, c.destination)
  64. self.assertIn('_img', self.get_image_url(c.image + ' img'))
  65. if len(description) > 0:
  66. self.assert_text(description, c.description)
  67. if large:
  68. self.assert_element_visible('.card.large')
  69. else:
  70. self.assert_element_not_visible('.card.large')
  71. @parameterized.expand(no_thumb)
  72. def test_card_no_thumb(self, tweet, title, description, destination):
  73. self.open_nitter(tweet)
  74. c = Card(Conversation.main + " ")
  75. self.assert_text(title, c.title)
  76. self.assert_text(destination, c.destination)
  77. if len(description) > 0:
  78. self.assert_text(description, c.description)
  79. @parameterized.expand(playable)
  80. def test_card_playable(self, tweet, title, description, destination):
  81. self.open_nitter(tweet)
  82. c = Card(Conversation.main + " ")
  83. self.assert_text(title, c.title)
  84. self.assert_text(destination, c.destination)
  85. self.assertIn('_img', self.get_image_url(c.image + ' img'))
  86. self.assert_element_visible('.card-overlay')
  87. if len(description) > 0:
  88. self.assert_text(description, c.description)
  89. # @parameterized.expand(promo)
  90. # def test_card_promo(self, tweet, title, description, destination):
  91. # self.open_nitter(tweet)
  92. # c = Card(Conversation.main + " ")
  93. # self.assert_text(title, c.title)
  94. # self.assert_text(destination, c.destination)
  95. # self.assert_element_visible('.video-overlay')
  96. # if len(description) > 0:
  97. # self.assert_text(description, c.description)