test_card.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. ]
  13. no_thumb = [
  14. ['FluentAI/status/1116417904831029248',
  15. 'LinkedIn',
  16. 'This link will take you to a page that’s not on LinkedIn',
  17. 'lnkd.in'],
  18. ['Thom_Wolf/status/1122466524860702729',
  19. 'GitHub - facebookresearch/fairseq: Facebook AI Research Sequence-to-Sequence Toolkit written in',
  20. '',
  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. ['nim_lang/status/1118234460904919042',
  33. 'Nim development blog 2019-03',
  34. 'Arne (aka Krux02)* debugging: * improved nim-gdb, $ works, framefilter * alias for --debugger:native: -g* bugs: * forwarding of .pure. * sizeof union* fe...',
  35. 'youtube.com'],
  36. ['nim_lang/status/1121090879823986688',
  37. 'Nim - First natively compiled language w/ hot code-reloading at...',
  38. '#nim #c++ #ACCUConfNim is a statically typed systems and applications programming language which offers perhaps some of the most powerful metaprogramming cap...',
  39. 'youtube.com']
  40. ]
  41. class CardTest(BaseTestCase):
  42. @parameterized.expand(card)
  43. def test_card(self, tweet, title, description, destination, large):
  44. self.open_nitter(tweet)
  45. c = Card(Conversation.main + " ")
  46. self.assert_text(title, c.title)
  47. self.assert_text(destination, c.destination)
  48. self.assertIn('/pic/', self.get_image_url(c.image + ' img'))
  49. if len(description) > 0:
  50. self.assert_text(description, c.description)
  51. if large:
  52. self.assert_element_visible('.card.large')
  53. else:
  54. self.assert_element_not_visible('.card.large')
  55. @parameterized.expand(no_thumb)
  56. def test_card_no_thumb(self, tweet, title, description, destination):
  57. self.open_nitter(tweet)
  58. c = Card(Conversation.main + " ")
  59. self.assert_text(title, c.title)
  60. self.assert_text(destination, c.destination)
  61. if len(description) > 0:
  62. self.assert_text(description, c.description)
  63. @parameterized.expand(playable)
  64. def test_card_playable(self, tweet, title, description, destination):
  65. self.open_nitter(tweet)
  66. c = Card(Conversation.main + " ")
  67. self.assert_text(title, c.title)
  68. self.assert_text(destination, c.destination)
  69. self.assertIn('/pic/', self.get_image_url(c.image + ' img'))
  70. self.assert_element_visible('.card-overlay')
  71. if len(description) > 0:
  72. self.assert_text(description, c.description)