def videos_handler(request, course_key_string, edx_video_id=None): """ The restful handler for video uploads. GET html: return an HTML page to display previous video uploads and allow new ones json: return json representing the videos that have been uploaded and their statuses POST json: create a new video upload; the actual files should not be provided to this endpoint but rather PUT to the respective upload_url values contained in the response DELETE soft deletes a video for particular course """ course = _get_and_validate_course(course_key_string, request.user) if not course: return HttpResponseNotFound() if request.method == "GET": if "application/json" in request.META.get("HTTP_ACCEPT", ""): return videos_index_json(course) else: return videos_index_html(course) elif request.method == "DELETE": remove_video_for_course(course_key_string, edx_video_id) return JsonResponse() else: if is_status_update_request(request.json): return send_video_status_update(request.json) return videos_post(course, request)
def test_remove_video_for_course(self): """ Tests video removal for a course """ # we have one video for this course videos = list(api.get_videos_for_course(self.course_id)) self.assertEqual(len(videos), 1) # remove the video and verify that video is removed from correct course api.remove_video_for_course(self.course_id, self.edx_video_id) videos = list(api.get_videos_for_course(self.course_id)) self.assertEqual(len(videos), 0) # verify that CourseVideo related object exists(soft removal) for removed video course_video = CourseVideo.objects.get( course_id=self.course_id, video__edx_video_id=self.edx_video_id) self.assertEqual(course_video.is_hidden, True) # verify that video still exists for other course videos = list(api.get_videos_for_course('other-course')) self.assertEqual(len(videos), 1) # verify that video for other course has the correct info video_info = {key: videos[0][key] for key in constants.VIDEO_DICT_FISH} self.assertEqual(video_info, constants.VIDEO_DICT_FISH)
def test_incomplete_data_collection(self): """Ensure that missing video data prevents any estimates from being generated""" remove_video_for_course(str(self.course_key), 'edxval3') self.collect_and_transform() assert self.block_structure.get_transformer_data( EffortEstimationTransformer, DISABLE_ESTIMATION) is True assert self.block_structure.get_xblock_field(self.section_key, EFFORT_ACTIVITIES) is None assert self.block_structure.get_xblock_field(self.section_key, EFFORT_TIME) is None assert self.block_structure.get_xblock_field(self.subsection_key, EFFORT_ACTIVITIES) is None assert self.block_structure.get_xblock_field(self.subsection_key, EFFORT_TIME) is None