Add media tests
This commit is contained in:
parent
6176c6f668
commit
af167ddef4
2 changed files with 87 additions and 4 deletions
|
@ -36,6 +36,14 @@ class Poll(object):
|
||||||
leader = 'leader'
|
leader = 'leader'
|
||||||
|
|
||||||
|
|
||||||
|
class Media(object):
|
||||||
|
container = '.attachments'
|
||||||
|
row = '.gallery-row'
|
||||||
|
image = '.still-image'
|
||||||
|
video = '.gallery-video'
|
||||||
|
gif = '.gallery-gif'
|
||||||
|
|
||||||
|
|
||||||
class BaseTestCase(BaseCase):
|
class BaseTestCase(BaseCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseTestCase, self).setUp()
|
super(BaseTestCase, self).setUp()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from base import BaseTestCase, Poll
|
from base import BaseTestCase, Poll, Media
|
||||||
from parameterized import parameterized
|
from parameterized import parameterized
|
||||||
|
|
||||||
poll = [
|
poll = [
|
||||||
|
@ -11,6 +11,37 @@ poll = [
|
||||||
]]
|
]]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
image = [
|
||||||
|
['mobile_test/status/519364660823207936', 'BzUnaDFCUAAmrjs'],
|
||||||
|
['mobile_test_2/status/324619691039543297', 'BIFH45vCUAAQecj']
|
||||||
|
]
|
||||||
|
|
||||||
|
gif = [
|
||||||
|
['hot_pengu/status/1142904127594401797', 'D9xpM5eW4AIXfUl'],
|
||||||
|
['Proj_Borealis/status/1136595194621677568', 'D8X_PJAXUAAavPT']
|
||||||
|
]
|
||||||
|
|
||||||
|
video_m3u8 = [
|
||||||
|
['d0m96/status/1078373829917974528', '9q1-v9w8-ft3awgD.jpg'],
|
||||||
|
['SpaceX/status/1138474014152712192', 'ocJJj2uu4n1kyD2Y.jpg']
|
||||||
|
]
|
||||||
|
|
||||||
|
gallery = [
|
||||||
|
['mobile_test/status/451108446603980803', [
|
||||||
|
['BkKovdrCUAAEz79', 'BkKovdcCEAAfoBO']
|
||||||
|
]],
|
||||||
|
|
||||||
|
['mobile_test/status/471539824713691137', [
|
||||||
|
['Bos--KNIQAAA7Li', 'Bos--FAIAAAWpah'],
|
||||||
|
['Bos--IqIQAAav23']
|
||||||
|
]],
|
||||||
|
|
||||||
|
['mobile_test/status/469530783384743936', [
|
||||||
|
['BoQbwJAIUAA0QCY', 'BoQbwN1IMAAuTiP'],
|
||||||
|
['BoQbwarIAAAlaE-', 'BoQbwh_IEAA27ef']
|
||||||
|
]]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class MediaTest(BaseTestCase):
|
class MediaTest(BaseTestCase):
|
||||||
@parameterized.expand(poll)
|
@parameterized.expand(poll)
|
||||||
|
@ -20,9 +51,7 @@ class MediaTest(BaseTestCase):
|
||||||
self.assert_text(votes, Poll.votes)
|
self.assert_text(votes, Poll.votes)
|
||||||
|
|
||||||
poll_choices = self.find_elements(Poll.choice)
|
poll_choices = self.find_elements(Poll.choice)
|
||||||
for i in range(len(choices)):
|
for i, (v, o) in enumerate(choices):
|
||||||
v, o = choices[i]
|
|
||||||
|
|
||||||
choice = poll_choices[i]
|
choice = poll_choices[i]
|
||||||
value = choice.find_element_by_class_name(Poll.value)
|
value = choice.find_element_by_class_name(Poll.value)
|
||||||
option = choice.find_element_by_class_name(Poll.option)
|
option = choice.find_element_by_class_name(Poll.option)
|
||||||
|
@ -35,3 +64,49 @@ class MediaTest(BaseTestCase):
|
||||||
self.assertIn(Poll.leader, choice_class)
|
self.assertIn(Poll.leader, choice_class)
|
||||||
else:
|
else:
|
||||||
self.assertNotIn(Poll.leader, choice_class)
|
self.assertNotIn(Poll.leader, choice_class)
|
||||||
|
|
||||||
|
@parameterized.expand(image)
|
||||||
|
def test_image(self, tweet, url):
|
||||||
|
self.open_nitter(tweet)
|
||||||
|
self.assert_element_visible(Media.container)
|
||||||
|
self.assert_element_visible(Media.image)
|
||||||
|
|
||||||
|
image_url = self.get_image_url(Media.image + ' img')
|
||||||
|
self.assertIn(url, image_url)
|
||||||
|
|
||||||
|
@parameterized.expand(gif)
|
||||||
|
def test_gif(self, tweet, gif_id):
|
||||||
|
self.open_nitter(tweet)
|
||||||
|
self.assert_element_visible(Media.container)
|
||||||
|
self.assert_element_visible(Media.gif)
|
||||||
|
|
||||||
|
url = self.get_attribute('source', 'src')
|
||||||
|
thumb = self.get_attribute('video', 'poster')
|
||||||
|
self.assertIn(gif_id + '.mp4', url)
|
||||||
|
self.assertIn(gif_id + '.jpg', thumb)
|
||||||
|
|
||||||
|
@parameterized.expand(video_m3u8)
|
||||||
|
def test_video_m3u8(self, tweet, thumb):
|
||||||
|
# no url because video playback isn't supported yet
|
||||||
|
self.open_nitter(tweet)
|
||||||
|
self.assert_element_visible(Media.container)
|
||||||
|
self.assert_element_visible(Media.video)
|
||||||
|
|
||||||
|
video_thumb = self.get_attribute('video', 'poster')
|
||||||
|
self.assertIn(thumb, video_thumb)
|
||||||
|
|
||||||
|
@parameterized.expand(gallery)
|
||||||
|
def test_gallery(self, tweet, rows):
|
||||||
|
self.open_nitter(tweet)
|
||||||
|
self.assert_element_visible(Media.container)
|
||||||
|
self.assert_element_visible(Media.row)
|
||||||
|
self.assert_element_visible(Media.image)
|
||||||
|
|
||||||
|
gallery_rows = self.find_elements(Media.row)
|
||||||
|
self.assert_equal(len(rows), len(gallery_rows))
|
||||||
|
|
||||||
|
for i, row in enumerate(gallery_rows):
|
||||||
|
images = row.find_elements_by_css_selector('img')
|
||||||
|
self.assert_equal(len(rows[i]), len(images))
|
||||||
|
for j, image in enumerate(images):
|
||||||
|
self.assertIn(rows[i][j], image.get_attribute('src'))
|
||||||
|
|
Loading…
Reference in a new issue