test_card.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. ['FluentAI/status/1116417904831029248',
  13. 'Amazon’s Alexa isn’t just AI — thousands of humans are listening',
  14. 'One of the only ways to improve Alexa is to have human beings check it for errors',
  15. 'theverge.com', True]
  16. ]
  17. no_thumb = [
  18. ['Thom_Wolf/status/1122466524860702729',
  19. 'facebookresearch/fairseq',
  20. 'Facebook AI Research Sequence-to-Sequence Toolkit written in Python. - GitHub - facebookresearch/fairseq: Facebook AI Research Sequence-to-Sequence Toolkit written in Python.',
  21. 'github.com'],
  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. ['nim_lang/status/1082989146040340480',
  31. 'Nim in 2018: A short recap',
  32. 'Posted by u/miran1 - 36 votes and 46 comments',
  33. 'reddit.com']
  34. ]
  35. playable = [
  36. ['nim_lang/status/1118234460904919042',
  37. 'Nim development blog 2019-03',
  38. 'Arne (aka Krux02)* debugging: * improved nim-gdb, $ works, framefilter * alias for --debugger:native: -g* bugs: * forwarding of .pure. * sizeof union* fe...',
  39. 'youtube.com'],
  40. ['nim_lang/status/1121090879823986688',
  41. 'Nim - First natively compiled language w/ hot code-reloading at...',
  42. '#nim #c++ #ACCUConfNim is a statically typed systems and applications programming language which offers perhaps some of the most powerful metaprogramming cap...',
  43. 'youtube.com']
  44. ]
  45. # promo = [
  46. # ['BangOlufsen/status/1145698701517754368',
  47. # 'Upgrade your journey', '',
  48. # 'www.bang-olufsen.com'],
  49. # ['BangOlufsen/status/1154934429900406784',
  50. # 'Learn more about Beosound Shape', '',
  51. # 'www.bang-olufsen.com']
  52. # ]
  53. class CardTest(BaseTestCase):
  54. @parameterized.expand(card)
  55. def test_card(self, tweet, title, description, destination, large):
  56. self.open_nitter(tweet)
  57. c = Card(Conversation.main + " ")
  58. self.assert_text(title, c.title)
  59. self.assert_text(destination, c.destination)
  60. self.assertIn('/pic/', self.get_image_url(c.image + ' img'))
  61. if len(description) > 0:
  62. self.assert_text(description, c.description)
  63. if large:
  64. self.assert_element_visible('.card.large')
  65. else:
  66. self.assert_element_not_visible('.card.large')
  67. @parameterized.expand(no_thumb)
  68. def test_card_no_thumb(self, tweet, title, description, destination):
  69. self.open_nitter(tweet)
  70. c = Card(Conversation.main + " ")
  71. self.assert_text(title, c.title)
  72. self.assert_text(destination, c.destination)
  73. if len(description) > 0:
  74. self.assert_text(description, c.description)
  75. @parameterized.expand(playable)
  76. def test_card_playable(self, tweet, title, description, destination):
  77. self.open_nitter(tweet)
  78. c = Card(Conversation.main + " ")
  79. self.assert_text(title, c.title)
  80. self.assert_text(destination, c.destination)
  81. self.assertIn('/pic/', self.get_image_url(c.image + ' img'))
  82. self.assert_element_visible('.card-overlay')
  83. if len(description) > 0:
  84. self.assert_text(description, c.description)
  85. # @parameterized.expand(promo)
  86. # def test_card_promo(self, tweet, title, description, destination):
  87. # self.open_nitter(tweet)
  88. # c = Card(Conversation.main + " ")
  89. # self.assert_text(title, c.title)
  90. # self.assert_text(destination, c.destination)
  91. # self.assert_element_visible('.video-overlay')
  92. # if len(description) > 0:
  93. # self.assert_text(description, c.description)