test_card.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import os
  2. import unittest
  3. from base import BaseTestCase, Card, Conversation
  4. from parameterized import parameterized
  5. card = [
  6. ['nim_lang/status/1136652293510717440',
  7. 'Version 0.20.0 released',
  8. '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!',
  9. 'nim-lang.org', True],
  10. ['voidtarget/status/1094632512926605312',
  11. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too)',
  12. 'Basic OBS Studio plugin, written in nim, supporting C++ (C fine too) - obsplugin.nim',
  13. 'gist.github.com', True],
  14. ['NASA/status/2061872347477418301',
  15. 'Nancy Grace Roman Space Telescope - NASA Science',
  16. 'The Nancy Grace Roman Space Telescope will settle essential questions in the areas of dark energy, exoplanets, and astrophysics.',
  17. 'science.nasa.gov', True]
  18. ]
  19. no_thumb = [
  20. ['Thom_Wolf/status/1122466524860702729',
  21. 'GitHub - facebookresearch/XLM: PyTorch original implementation of Cross-lingual Language Model',
  22. 'PyTorch original implementation of Cross-lingual Language Model Pretraining.',
  23. 'github.com'],
  24. ['brent_p/status/1088857328680488961',
  25. 'GitHub - brentp/hts-nim: nim wrapper for htslib for parsing genomics data files',
  26. '',
  27. 'github.com'],
  28. ['voidtarget/status/1133028231672582145',
  29. 'sinkingsugar/nimqt-example',
  30. 'A sample of a Qt app written using mostly nim. Contribute to sinkingsugar/nimqt-example development by creating an account on GitHub.',
  31. 'github.com']
  32. ]
  33. playable = [
  34. ['NASA/status/2047048645845897398',
  35. 'NASA\'s Artemis II News Conference with Moon Astronauts',
  36. 'Live from NASA\'s Johnson Space Center in Houston',
  37. 'youtube.com']
  38. ]
  39. class CardTest(BaseTestCase):
  40. @parameterized.expand(card)
  41. def test_card(self, tweet, title, description, destination, large):
  42. if os.environ.get('GITHUB_ACTIONS') == 'true' and '2061872347477418301' in tweet:
  43. self.skipTest('Card image unreliable from GitHub datacenter IPs')
  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, skip_on_empty=True)
  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)