Commit 41fd2e4d by Will Daly

Test case for updating courses

parent c0c975f8
......@@ -268,6 +268,22 @@ COMPLETE_SET_UPDATE_STAR = dict(
subtitles=[SUBTITLE_DICT_SRT],
**VIDEO_DICT_STAR
)
COMPLETE_SET_WITH_COURSE_KEY = dict(
courses=['edX/DemoX/Demo_Course'],
encoded_videos=[
ENCODED_VIDEO_UPDATE_DICT_STAR
],
subtitles=[SUBTITLE_DICT_SRT],
**VIDEO_DICT_STAR
)
COMPLETE_SET_WITH_OTHER_COURSE_KEYS = dict(
courses=['edX/DemoX/Astonomy', 'edX/DemoX/Zoology'],
encoded_videos=[
ENCODED_VIDEO_UPDATE_DICT_STAR
],
subtitles=[SUBTITLE_DICT_SRT],
**VIDEO_DICT_STAR
)
COMPLETE_SET_NOT_A_LIST = dict(
encoded_videos=dict(
url="https://www.howIwonder.com",
......
......@@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse
from rest_framework import status
from edxval.tests import constants, APIAuthTestCase
from edxval.models import Profile, Video
from edxval.models import Profile, Video, CourseVideo
class VideoDetail(APIAuthTestCase):
......@@ -207,6 +207,30 @@ class VideoDetail(APIAuthTestCase):
)
self.assertEqual(len(videos[0].encoded_videos.all()), 1)
def test_update_courses(self):
# Create the video with associated course keys
url = reverse('video-list')
response = self.client.post(url, constants.COMPLETE_SET_WITH_COURSE_KEY, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# Verify that the video was associated with the courses
video = Video.objects.get()
course_keys = [c.course_id for c in CourseVideo.objects.filter(video=video)]
self.assertEqual(course_keys, constants.COMPLETE_SET_WITH_COURSE_KEY["courses"])
# Update the video to associate it with other courses
url = reverse('video-detail', kwargs={"edx_video_id": video.edx_video_id})
response = self.client.put(
url,
constants.COMPLETE_SET_WITH_OTHER_COURSE_KEYS,
format='json'
)
self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response.content)
# Verify that the video's courses were updated
course_keys = [c.course_id for c in CourseVideo.objects.filter(video=video)]
self.assertEqual(course_keys, constants.COMPLETE_SET_WITH_OTHER_COURSE_KEYS["courses"])
def test_update_invalid_video(self):
"""
Tests PUTting a video with different edx_video_id.
......
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