Commit 97440578 by Dennis Jen

Added video and video timeline.

parent 56f111cd
......@@ -104,3 +104,13 @@ class Course(object):
"""
path = 'courses/{0}/problems/'.format(self.course_id)
return self.client.get(path, data_format=data_format)
def videos(self, data_format=DF.JSON):
"""
Get the videos for the course.
Arguments:
data_format (str): Format in which data should be returned
"""
path = 'courses/{0}/videos/'.format(self.course_id)
return self.client.get(path, data_format=data_format)
......@@ -49,3 +49,14 @@ class Module(object):
path = 'problems/{0}/sequential_open_distribution/'.format(self.module_id)
return self.client.get(path, data_format=data_format)
def video_timeline(self, data_format=DF.JSON):
"""
Get video segments/timeline for a module.
Arguments:
data_format (str): Format in which to return data (default is JSON)
"""
path = 'videos/{0}/timeline/'.format(self.module_id)
return self.client.get(path, data_format=data_format)
......@@ -147,3 +147,22 @@ class CoursesTests(ClientTestCase):
uri = self.get_api_url('courses/{0}/problems/'.format(self.course_id))
httpretty.register_uri(httpretty.GET, uri, body=json.dumps(body))
self.assertEqual(body, self.course.problems())
@httpretty.activate
def test_videos(self):
body = [
{
'pipeline_video_id': '0fac49ba',
'encoded_module_id': 'i4x-a-b-c',
'duration': 600,
'segment_length': 5,
'start_views': 50,
'end_views': 1,
'created': '2015-01-01T00:01:00'
}
]
uri = self.get_api_url('courses/{0}/videos/'.format(self.course_id))
httpretty.register_uri(httpretty.GET, uri, body=json.dumps(body))
self.assertEqual(body, self.course.videos())
......@@ -95,3 +95,19 @@ class ModulesTests(ClientTestCase):
uri = self.get_api_url('problems/{0}/grade_distribution/'.format(self.module_id))
httpretty.register_uri(httpretty.GET, uri, body=json.dumps(body))
self.assertEqual(body, self.module.grade_distribution())
@httpretty.activate
def test_video_timeline_response(self):
""" Verifies that the video timeline responds with the expected values. """
body = [
{
'segment': 0,
'num_users': 140,
'num_views': 64234,
'created': '2014-01-01T00:01:00'
}
]
uri = self.get_api_url('videos/{0}/timeline/'.format(self.module_id))
httpretty.register_uri(httpretty.GET, uri, body=json.dumps(body))
self.assertEqual(body, self.module.video_timeline())
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