test_card.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. from base import BaseTestCase, Card, Conversation
  2. from parameterized import parameterized
  3. card = [
  4. ['voidtarget/status/1133028231672582145',
  5. 'sinkingsugar/nimqt-example',
  6. 'A sample of a Qt app written using mostly nim. Contribute to sinkingsugar/nimqt-example development by creating an account on GitHub.',
  7. 'github.com', False],
  8. ['lorenlugosch/status/1115440394148487168',
  9. 'lorenlugosch/pretrain_speech_model',
  10. 'Speech Model Pre-training for End-to-End Spoken Language Understanding - lorenlugosch/pretrain_speech_model',
  11. 'github.com', False],
  12. ['PyTorch/status/1123379369672450051',
  13. 'PyTorch',
  14. 'An open source deep learning platform that provides a seamless path from research prototyping to production deployment.',
  15. 'pytorch.org', False],
  16. ['Thom_Wolf/status/1122466524860702729',
  17. 'pytorch/fairseq',
  18. 'Facebook AI Research Sequence-to-Sequence Toolkit written in Python. - pytorch/fairseq',
  19. 'github.com', False],
  20. ['TheTwoffice/status/558685306090946561',
  21. 'Eternity: a moment standing still forever…',
  22. '- James Montgomery. | facebook | 500px | ferpectshotz | I dusted off this one from my old archives, it was taken while I was living in mighty new York city working at Wall St. I think this was the 11...',
  23. 'flickr.com', True],
  24. ['nim_lang/status/1136652293510717440',
  25. 'Version 0.20.0 released',
  26. '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!',
  27. 'nim-lang.org', True],
  28. ['nim_lang/status/1082989146040340480',
  29. 'Nim in 2018: A short recap',
  30. 'Posted in r/programming by u/miran1',
  31. 'reddit.com', False],
  32. ['Tesla/status/1141041022035623936',
  33. 'Experience the Tesla Arcade',
  34. '',
  35. 'www.tesla.com', True],
  36. ['mobile_test/status/490378953744318464',
  37. 'Nantasket Beach',
  38. 'Rocks on the beach.',
  39. '500px.com', True],
  40. ['voidtarget/status/1094632512926605312',
  41. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too)',
  42. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too) - obsplugin.nim',
  43. 'gist.github.com', True],
  44. ['AdsAPI/status/1110272721005367296',
  45. 'Conversation Targeting',
  46. '',
  47. 'view.highspot.com', True],
  48. ['FluentAI/status/1116417904831029248',
  49. 'Amazon’s Alexa isn’t just AI — thousands of humans are listening',
  50. 'One of the only ways to improve Alexa is to have human beings check it for errors',
  51. 'theverge.com', True]
  52. ]
  53. no_thumb = [
  54. ['Bountysource/status/1141879700639215617',
  55. '$1,000 Bounty on kivy/plyer',
  56. 'Automation and Screen Reader Support',
  57. 'bountysource.com'],
  58. ['brent_p/status/1088857328680488961',
  59. 'Hts Nim Sugar',
  60. '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...',
  61. 'brentp.github.io']
  62. ]
  63. playable = [
  64. ['nim_lang/status/1118234460904919042',
  65. 'Nim development blog 2019-03',
  66. 'Arne (aka Krux02) * debugging: * improved nim-gdb, $ works, framefilter * alias for --debugger:native: -g * bugs: * forwarding of .pure. * sizeof union * fea...',
  67. 'youtube.com'],
  68. ['nim_lang/status/1121090879823986688',
  69. 'Nim - First natively compiled language w/ hot code-reloading at...',
  70. '#nim #c++ #ACCUConf Nim is a statically typed systems and applications programming language which offers perhaps some of the most powerful metaprogramming ca...',
  71. 'youtube.com'],
  72. ['lele/status/819930645145288704',
  73. 'Eurocrash presents Open Decks - emerging dj #4: E-Musik',
  74. "OPEN DECKS is Eurocrash's new project about discovering new and emerging dj talents. Every selected dj will have the chance to perform the first dj-set in front of an actual audience. The best dj...",
  75. 'mixcloud.com']
  76. ]
  77. promo = [
  78. ['BangOlufsen/status/1145698701517754368',
  79. 'Upgrade your journey', '',
  80. 'www.bang-olufsen.com'],
  81. ['BangOlufsen/status/1154934429900406784',
  82. 'Learn more about Beosound Shape', '',
  83. 'www.bang-olufsen.com']
  84. ]
  85. class CardTest(BaseTestCase):
  86. @parameterized.expand(card)
  87. def test_card(self, tweet, title, description, destination, large):
  88. self.open_nitter(tweet)
  89. card = Card(Conversation.main + " ")
  90. self.assert_text(title, card.title)
  91. self.assert_text(destination, card.destination)
  92. self.assertIn('_img', self.get_image_url(card.image + ' img'))
  93. if len(description) > 0:
  94. self.assert_text(description, card.description)
  95. if large:
  96. self.assert_element_visible('.card.large')
  97. else:
  98. self.assert_element_not_visible('.card.large')
  99. @parameterized.expand(no_thumb)
  100. def test_card_no_thumb(self, tweet, title, description, destination):
  101. self.open_nitter(tweet)
  102. card = Card(Conversation.main + " ")
  103. self.assert_text(title, card.title)
  104. self.assert_text(destination, card.destination)
  105. if len(description) > 0:
  106. self.assert_text(description, card.description)
  107. @parameterized.expand(playable)
  108. def test_card_playable(self, tweet, title, description, destination):
  109. self.open_nitter(tweet)
  110. card = Card(Conversation.main + " ")
  111. self.assert_text(title, card.title)
  112. self.assert_text(destination, card.destination)
  113. self.assertIn('_img', self.get_image_url(card.image + ' img'))
  114. self.assert_element_visible('.card-overlay')
  115. if len(description) > 0:
  116. self.assert_text(description, card.description)
  117. @parameterized.expand(promo)
  118. def test_card_promo(self, tweet, title, description, destination):
  119. self.open_nitter(tweet)
  120. card = Card(Conversation.main + " ")
  121. self.assert_text(title, card.title)
  122. self.assert_text(destination, card.destination)
  123. self.assert_element_visible('.video-overlay')
  124. if len(description) > 0:
  125. self.assert_text(description, card.description)