Commit 5abd4f7e by Dave St.Germain

Merge pull request #16 from edx/dcs/youtube-support

Support youtube encoded videos by using a different Profile.
parents 42d1a0c2 eabdb278
[
{
"pk": 1,
"model": "edxval.profile",
"fields": {
"width": 1920,
"profile_name": "youtube",
"extension": "mp4",
"height": 1080
}
},
{
"pk": 2,
"model": "edxval.profile",
"fields": {
"width": 1280,
"profile_name": "desktop_mp4",
"extension": "mp4",
"height": 720
}
},
{
"pk": 3,
"model": "edxval.profile",
"fields": {
"width": 1280,
"profile_name": "desktop_webm",
"extension": "webm",
"height": 720
}
},
{
"pk": 4,
"model": "edxval.profile",
"fields": {
"width": 960,
"profile_name": "mobile_high",
"extension": "mp4",
"height": 540
}
},
{
"pk": 5,
"model": "edxval.profile",
"fields": {
"width": 640,
"profile_name": "mobile_low",
"extension": "mp4",
"height": 360
}
}
]
\ No newline at end of file
...@@ -19,6 +19,12 @@ PROFILE_DICT_DESKTOP = dict( ...@@ -19,6 +19,12 @@ PROFILE_DICT_DESKTOP = dict(
width=200, width=200,
height=2001 height=2001
) )
PROFILE_DICT_YOUTUBE = dict(
profile_name="youtube",
extension="mp4",
width=1280,
height=720
)
""" """
Encoded_videos for test_api, does not have profile. Encoded_videos for test_api, does not have profile.
""" """
...@@ -147,6 +153,12 @@ ENCODED_VIDEO_DICT_FISH_MOBILE = dict( ...@@ -147,6 +153,12 @@ ENCODED_VIDEO_DICT_FISH_MOBILE = dict(
bitrate=42, bitrate=42,
profile="mobile", profile="mobile",
) )
ENCODED_VIDEO_DICT_FISH_YOUTUBE = dict(
url="https://www.youtube.com/watch?v=OscRe3pSP80",
file_size=0,
bitrate=42,
profile="youtube",
)
ENCODED_VIDEO_DICT_FISH_DESKTOP = dict( ENCODED_VIDEO_DICT_FISH_DESKTOP = dict(
url="https://www.swordsplints.com", url="https://www.swordsplints.com",
file_size=1234, file_size=1234,
......
...@@ -88,13 +88,13 @@ class CreateProfileTest(TestCase): ...@@ -88,13 +88,13 @@ class CreateProfileTest(TestCase):
Tests the creation of a profile Tests the creation of a profile
""" """
result = api.create_profile(constants.PROFILE_DICT_DESKTOP) result = api.create_profile(constants.PROFILE_DICT_DESKTOP)
profiles = Profile.objects.all() profiles = list(Profile.objects.all())
self.assertEqual(len(profiles), 1) self.assertEqual(len(profiles), 6)
self.assertEqual( self.assertEqual(
profiles[0].profile_name, profiles[-1].profile_name,
constants.PROFILE_DICT_DESKTOP.get('profile_name') constants.PROFILE_DICT_DESKTOP.get('profile_name')
) )
self.assertEqual(len(profiles), 1) self.assertEqual(len(profiles), 6)
self.assertEqual("desktop", result) self.assertEqual("desktop", result)
@data( @data(
......
...@@ -399,6 +399,28 @@ class VideoListTest(APIAuthTestCase): ...@@ -399,6 +399,28 @@ class VideoListTest(APIAuthTestCase):
videos = len(self.client.get("/edxval/video/").data) videos = len(self.client.get("/edxval/video/").data)
self.assertEqual(videos, 1) self.assertEqual(videos, 1)
def test_post_with_youtube(self):
"""
Test that youtube is a valid profile.
"""
url = reverse('video-list')
video_data = dict(
encoded_videos=[
constants.ENCODED_VIDEO_DICT_FISH_MOBILE,
constants.ENCODED_VIDEO_DICT_FISH_YOUTUBE
],
**constants.VIDEO_DICT_FISH
)
response = self.client.post(
url, video_data, format='json'
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
videos = self.client.get("/edxval/video/").data
self.assertEqual(len(videos), 1)
self.assertIn('youtube.com', videos[0]['encoded_videos'][1]['url'])
def test_complete_set_invalid_encoded_video_post(self): def test_complete_set_invalid_encoded_video_post(self):
""" """
Tests POSTing valid Video and partial valid EncodedVideos. Tests POSTing valid Video and partial valid EncodedVideos.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment