Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover html5 backend with unit tests #167

Merged
merged 17 commits into from
Mar 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions video_xblock/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ class TestCustomBackends(VideoXBlockTestBase):
Unit tests for custom video xblock backends.
"""
backends = ['youtube', 'brightcove', 'wistia', 'vimeo', 'html5']
media_ids = ['44zaxzFsthY', '45263567468485', 'HRrr784kH8932Z', '202889234']
media_urls = [
'https://www.youtube.com/watch?v=44zaxzFsthY',
'https://studio.brightcove.com/products/videocloud/media/videos/45263567468485',
'https://wi.st/medias/HRrr784kH8932Z',
'https://vimeo.com/202889234'
]

auth_mocks = [
youtube_mock.YoutubeAuthMock,
Expand Down Expand Up @@ -95,20 +88,6 @@ def test_get_player_html(self):
res = player(self.xblock).get_player_html(**context)
self.assertIn('window.videojs', res.body)

@data(*zip(backends, media_urls))
@unpack
def test_match(self, backend, url):
"""
Check if provided video `href` validates in right way.
"""
player = self.player[backend]
res = player.match(url)
self.assertTrue(bool(res))

# test wrong data
res = player.match('http://wrong.url')
self.assertFalse(bool(res))

expected_basic_fields = [
('display_name', 'href'),
('display_name', 'href', 'account_id'),
Expand Down Expand Up @@ -189,16 +168,42 @@ def test_get_transcript_language_parameters(self, lng_abbr, lng_name):
except VideoXBlockException as ex:
self.assertIn(_('Not all the languages of transcripts fetched from video platform'), ex.message)

media_ids = [
'44zaxzFsthY', '45263567468485', 'HRrr784kH8932Z', '202889234',
'https://example.com/sample.mp4'
]
media_urls = [
'https://www.youtube.com/watch?v=44zaxzFsthY',
'https://studio.brightcove.com/products/videocloud/media/videos/45263567468485',
'https://wi.st/medias/HRrr784kH8932Z',
'https://vimeo.com/202889234',
'https://example.com/sample.mp4',
]

@data(*zip(backends, media_urls, media_ids))
@unpack
def test_media_id(self, backend, url, expected_media_id):
"""
Check that media id is extracted from the video url.
Check that media id is extracted from the video url for {0} backend
"""
player = self.player[backend](self.xblock)
res = player.media_id(url)
self.assertEqual(res, expected_media_id)

@data(*zip(backends, media_urls))
@unpack
def test_match(self, backend, url):
"""
Check if provided video `href` validates in right way for {0} backend
"""
player = self.player[backend]
res = player.match(url)
self.assertTrue(bool(res))

# test wrong data
res = player.match('http://wrong.url')
self.assertFalse(bool(res))

@data(*zip(backends, ['some_token'] * len(backends), auth_mocks))
@unpack
def test_authenticate_api(self, backend, token, auth_mock):
Expand Down