test_card.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. from base import BaseTestCase, Card, Conversation
  2. from parameterized import parameterized
  3. card = [
  4. ['lorenlugosch/status/1115440394148487168',
  5. 'lorenlugosch/end-to-end-SLU',
  6. 'PyTorch code for end-to-end spoken language understanding (SLU) with ASR-based transfer learning - lorenlugosch/end-to-end-SLU',
  7. 'github.com', False],
  8. ['PyTorch/status/1123379369672450051',
  9. 'PyTorch',
  10. 'An open source deep learning platform that provides a seamless path from research prototyping to production deployment.',
  11. 'pytorch.org', False],
  12. ['Thom_Wolf/status/1122466524860702729',
  13. 'pytorch/fairseq',
  14. 'Facebook AI Research Sequence-to-Sequence Toolkit written in Python. - pytorch/fairseq',
  15. 'github.com', False],
  16. ['TheTwoffice/status/558685306090946561',
  17. 'Eternity: a moment standing still forever…',
  18. '- 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...',
  19. 'flickr.com', True],
  20. ['nim_lang/status/1136652293510717440',
  21. 'Version 0.20.0 released',
  22. '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!',
  23. 'nim-lang.org', True],
  24. ['Tesla/status/1141041022035623936',
  25. 'Experience the Tesla Arcade',
  26. '',
  27. 'www.tesla.com', True],
  28. ['voidtarget/status/1094632512926605312',
  29. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too)',
  30. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too) - obsplugin.nim',
  31. 'gist.github.com', True],
  32. ['AdsAPI/status/1110272721005367296',
  33. 'Conversation Targeting',
  34. '',
  35. 'view.highspot.com', True],
  36. ['FluentAI/status/1116417904831029248',
  37. 'Amazon’s Alexa isn’t just AI — thousands of humans are listening',
  38. 'One of the only ways to improve Alexa is to have human beings check it for errors',
  39. 'theverge.com', True]
  40. ]
  41. no_thumb = [
  42. ['Bountysource/status/1141879700639215617',
  43. 'Post a bounty on kivy/plyer!',
  44. 'Automation and Screen Reader Support',
  45. 'bountysource.com'],
  46. ['brent_p/status/1088857328680488961',
  47. 'Hts Nim Sugar',
  48. '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...',
  49. 'brentp.github.io'],
  50. ['voidtarget/status/1133028231672582145',
  51. 'sinkingsugar/nimqt-example',
  52. 'A sample of a Qt app written using mostly nim. Contribute to sinkingsugar/nimqt-example development by creating an account on GitHub.',
  53. 'github.com'],
  54. ['mobile_test/status/490378953744318464',
  55. 'Nantasket Beach',
  56. 'Rocks on the beach.',
  57. '500px.com'],
  58. ['nim_lang/status/1082989146040340480',
  59. 'Nim in 2018: A short recap',
  60. 'Posted in r/programming by u/miran1',
  61. 'reddit.com'],
  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. ]
  73. promo = [
  74. ['BangOlufsen/status/1145698701517754368',
  75. 'Upgrade your journey', '',
  76. 'www.bang-olufsen.com'],
  77. ['BangOlufsen/status/1154934429900406784',
  78. 'Learn more about Beosound Shape', '',
  79. 'www.bang-olufsen.com']
  80. ]
  81. class CardTest(BaseTestCase):
  82. @parameterized.expand(card)
  83. def test_card(self, tweet, title, description, destination, large):
  84. self.open_nitter(tweet)
  85. card = Card(Conversation.main + " ")
  86. self.assert_text(title, card.title)
  87. self.assert_text(destination, card.destination)
  88. self.assertIn('_img', self.get_image_url(card.image + ' img'))
  89. if len(description) > 0:
  90. self.assert_text(description, card.description)
  91. if large:
  92. self.assert_element_visible('.card.large')
  93. else:
  94. self.assert_element_not_visible('.card.large')
  95. @parameterized.expand(no_thumb)
  96. def test_card_no_thumb(self, tweet, title, description, destination):
  97. self.open_nitter(tweet)
  98. card = Card(Conversation.main + " ")
  99. self.assert_text(title, card.title)
  100. self.assert_text(destination, card.destination)
  101. if len(description) > 0:
  102. self.assert_text(description, card.description)
  103. @parameterized.expand(playable)
  104. def test_card_playable(self, tweet, title, description, destination):
  105. self.open_nitter(tweet)
  106. card = Card(Conversation.main + " ")
  107. self.assert_text(title, card.title)
  108. self.assert_text(destination, card.destination)
  109. self.assertIn('_img', self.get_image_url(card.image + ' img'))
  110. self.assert_element_visible('.card-overlay')
  111. if len(description) > 0:
  112. self.assert_text(description, card.description)
  113. @parameterized.expand(promo)
  114. def test_card_promo(self, tweet, title, description, destination):
  115. self.open_nitter(tweet)
  116. card = Card(Conversation.main + " ")
  117. self.assert_text(title, card.title)
  118. self.assert_text(destination, card.destination)
  119. self.assert_element_visible('.video-overlay')
  120. if len(description) > 0:
  121. self.assert_text(description, card.description)