test_card.py 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. ['nim_lang/status/1082989146040340480',
  17. 'Nim in 2018: A short recap',
  18. 'There were several big news in the Nim world in 2018 – two new major releases, partnership with Status, and much more. But let us go chronologically.',
  19. 'nim-lang.org', True]
  20. ]
  21. no_thumb = [
  22. ['Thom_Wolf/status/1122466524860702729',
  23. 'facebookresearch/fairseq',
  24. 'Facebook AI Research Sequence-to-Sequence Toolkit written in Python. - GitHub - facebookresearch/fairseq: Facebook AI Research Sequence-to-Sequence Toolkit written in Python.',
  25. 'github.com'],
  26. ['brent_p/status/1088857328680488961',
  27. 'Hts Nim Sugar',
  28. '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...',
  29. 'brentp.github.io'],
  30. ['voidtarget/status/1133028231672582145',
  31. 'sinkingsugar/nimqt-example',
  32. 'A sample of a Qt app written using mostly nim. Contribute to sinkingsugar/nimqt-example development by creating an account on GitHub.',
  33. 'github.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. class CardTest(BaseTestCase):
  46. @parameterized.expand(card)
  47. def test_card(self, tweet, title, description, destination, large):
  48. self.open_nitter(tweet)
  49. c = Card(Conversation.main + " ")
  50. self.assert_text(title, c.title)
  51. self.assert_text(destination, c.destination)
  52. self.assertIn('/pic/', self.get_image_url(c.image + ' img'))
  53. if len(description) > 0:
  54. self.assert_text(description, c.description)
  55. if large:
  56. self.assert_element_visible('.card.large')
  57. else:
  58. self.assert_element_not_visible('.card.large')
  59. @parameterized.expand(no_thumb)
  60. def test_card_no_thumb(self, tweet, title, description, destination):
  61. self.open_nitter(tweet)
  62. c = Card(Conversation.main + " ")
  63. self.assert_text(title, c.title)
  64. self.assert_text(destination, c.destination)
  65. if len(description) > 0:
  66. self.assert_text(description, c.description)
  67. @parameterized.expand(playable)
  68. def test_card_playable(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. self.assertIn('/pic/', self.get_image_url(c.image + ' img'))
  74. self.assert_element_visible('.card-overlay')
  75. if len(description) > 0:
  76. self.assert_text(description, c.description)