test_tweet_media.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from base import BaseTestCase, Poll
  2. from parameterized import parameterized
  3. poll = [
  4. ['nim_lang/status/1064219801499955200', 'Style insensitivity', '91', 1, [
  5. ('47%', 'Yay'), ('53%', 'Nay')
  6. ]],
  7. ['polls/status/1031986180622049281', 'What Tree Is Coolest?', '3,322', 1, [
  8. ('30%', 'Oak'), ('42%', 'Bonsai'), ('5%', 'Hemlock'), ('23%', 'Apple')
  9. ]]
  10. ]
  11. class MediaTest(BaseTestCase):
  12. @parameterized.expand(poll)
  13. def test_poll(self, tweet, text, votes, leader, choices):
  14. self.open_nitter(tweet)
  15. self.assert_text(text, '.main-tweet')
  16. self.assert_text(votes, Poll.votes)
  17. poll_choices = self.find_elements(Poll.choice)
  18. for i in range(len(choices)):
  19. v, o = choices[i]
  20. choice = poll_choices[i]
  21. value = choice.find_element_by_class_name(Poll.value)
  22. option = choice.find_element_by_class_name(Poll.option)
  23. choice_class = choice.get_attribute('class')
  24. self.assert_equal(v, value.text)
  25. self.assert_equal(o, option.text)
  26. if i == leader:
  27. self.assertIn(Poll.leader, choice_class)
  28. else:
  29. self.assertNotIn(Poll.leader, choice_class)