Add poll test
This commit is contained in:
parent
02f63f97d6
commit
6176c6f668
3 changed files with 47 additions and 0 deletions
|
@ -769,6 +769,8 @@ video {
|
|||
font-weight: bold;
|
||||
margin-left: 5px;
|
||||
margin-right: 6px;
|
||||
min-width: 30px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.poll-choice-option {
|
||||
|
|
|
@ -28,6 +28,14 @@ class Timeline(object):
|
|||
protected = '.timeline-protected'
|
||||
|
||||
|
||||
class Poll(object):
|
||||
votes = '.poll-info'
|
||||
choice = '.poll-meter'
|
||||
value = 'poll-choice-value'
|
||||
option = 'poll-choice-option'
|
||||
leader = 'leader'
|
||||
|
||||
|
||||
class BaseTestCase(BaseCase):
|
||||
def setUp(self):
|
||||
super(BaseTestCase, self).setUp()
|
||||
|
|
37
tests/test_tweet_media.py
Normal file
37
tests/test_tweet_media.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from base import BaseTestCase, Poll
|
||||
from parameterized import parameterized
|
||||
|
||||
poll = [
|
||||
['nim_lang/status/1064219801499955200', 'Style insensitivity', '91', 1, [
|
||||
('47%', 'Yay'), ('53%', 'Nay')
|
||||
]],
|
||||
|
||||
['polls/status/1031986180622049281', 'What Tree Is Coolest?', '3,322', 1, [
|
||||
('30%', 'Oak'), ('42%', 'Bonsai'), ('5%', 'Hemlock'), ('23%', 'Apple')
|
||||
]]
|
||||
]
|
||||
|
||||
|
||||
class MediaTest(BaseTestCase):
|
||||
@parameterized.expand(poll)
|
||||
def test_poll(self, tweet, text, votes, leader, choices):
|
||||
self.open_nitter(tweet)
|
||||
self.assert_text(text, '.main-tweet')
|
||||
self.assert_text(votes, Poll.votes)
|
||||
|
||||
poll_choices = self.find_elements(Poll.choice)
|
||||
for i in range(len(choices)):
|
||||
v, o = choices[i]
|
||||
|
||||
choice = poll_choices[i]
|
||||
value = choice.find_element_by_class_name(Poll.value)
|
||||
option = choice.find_element_by_class_name(Poll.option)
|
||||
choice_class = choice.get_attribute('class')
|
||||
|
||||
self.assert_equal(v, value.text)
|
||||
self.assert_equal(o, option.text)
|
||||
|
||||
if i == leader:
|
||||
self.assertIn(Poll.leader, choice_class)
|
||||
else:
|
||||
self.assertNotIn(Poll.leader, choice_class)
|
Loading…
Reference in a new issue