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

Extend Brightcove url regex to include additional set of video urls #182

Merged
merged 3 commits into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ clean: # Clean working directory

test: test-py test-js ## Run tests

test-py: deps-test ## Run Python tests
test-py: ## Run Python tests
nosetests video_xblock --with-coverage --cover-package=video_xblock

test-js: tools
test-js: ## Run JavaScript tests
karma start video_xblock/static/video_xblock_karma.conf.js

quality: quality-py quality-js ## Run code quality checks
Expand Down
2 changes: 1 addition & 1 deletion video_xblock/backends/brightcove.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class BrightcovePlayer(BaseVideoPlayer, BrightcoveHlsMixin):
BrightcovePlayer is used for videos hosted on the Brightcove Video Cloud.
"""

url_re = re.compile(r'https:\/\/studio.brightcove.com\/products\/videocloud\/media\/videos\/(?P<media_id>\d+)')
url_re = re.compile(r'https:\/\/studio.brightcove.com\/products(?:\/videocloud\/media)?\/videos\/(?P<media_id>\d+)')
metadata_fields = ['access_token', 'client_id', 'client_secret', ]

# Current api for requesting transcripts.
Expand Down
45 changes: 29 additions & 16 deletions video_xblock/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,36 +173,49 @@ def test_get_transcript_language_parameters(self, lng_abbr, lng_name):
'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',
[ # Youtube
'https://www.youtube.com/watch?v=44zaxzFsthY'
],
[ # Brightcove
'https://studio.brightcove.com/products/videocloud/media/videos/45263567468485',
'https://studio.brightcove.com/products/videos/45263567468485',
],
[ # Wistia
'https://wi.st/medias/HRrr784kH8932Z'
],
[ # Vimeo
'https://vimeo.com/202889234'
],
[ # Html5
'https://example.com/sample.mp4'
],
]

@data(*zip(backends, media_urls, media_ids))
@unpack
def test_media_id(self, backend, url, expected_media_id):
def test_media_id(self, backend, urls, expected_media_id):
"""
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)
for url in urls:
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):
def test_match(self, backend, urls):
"""
Check if provided video `href` validates in right way for {0} backend
"""
player = self.player[backend]
res = player.match(url)
self.assertTrue(bool(res))
for url in urls:
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))
# test wrong data
res = player.match('http://wrong.url')
self.assertFalse(bool(res))

@data(*zip(backends, ['some_token'] * len(backends), auth_mocks))
@unpack
Expand Down