Merge pull request #11985 from edx/clintonb/course-api-pacing
Added pacing field Course API
This commit is contained in:
@@ -55,6 +55,7 @@ class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-meth
|
||||
start = serializers.DateTimeField()
|
||||
start_display = serializers.CharField()
|
||||
start_type = serializers.CharField()
|
||||
pacing = serializers.CharField()
|
||||
|
||||
# 'course_id' is a deprecated field, please use 'id' instead.
|
||||
course_id = serializers.CharField(source='id', read_only=True)
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
Test data created by CourseSerializer and CourseDetailSerializer
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from datetime import datetime
|
||||
|
||||
import ddt
|
||||
from openedx.core.djangoapps.models.course_details import CourseDetails
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from rest_framework.test import APIRequestFactory
|
||||
@@ -18,6 +20,7 @@ from ..serializers import CourseSerializer, CourseDetailSerializer
|
||||
from .mixins import CourseApiFactoryMixin
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase):
|
||||
"""
|
||||
Test CourseSerializer
|
||||
@@ -54,6 +57,7 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase):
|
||||
'enrollment_end': u'2015-07-15T00:00:00Z',
|
||||
'blocks_url': u'http://testserver/api/courses/v1/blocks/?course_id=edX%2Ftoy%2F2012_Fall',
|
||||
'effort': u'6 hours',
|
||||
'pacing': 'instructor',
|
||||
|
||||
# 'course_id' is a deprecated field, please use 'id' instead.
|
||||
'course_id': u'edX/toy/2012_Fall',
|
||||
@@ -101,6 +105,16 @@ class TestCourseSerializer(CourseApiFactoryMixin, ModuleStoreTestCase):
|
||||
self.assertEqual(result['start_type'], u'empty')
|
||||
self.assertIsNone(result['start_display'])
|
||||
|
||||
@ddt.unpack
|
||||
@ddt.data(
|
||||
(True, 'self'),
|
||||
(False, 'instructor'),
|
||||
)
|
||||
def test_pacing(self, self_paced, expected_pacing):
|
||||
course = self.create_course(self_paced=self_paced)
|
||||
result = self._get_result(course)
|
||||
self.assertEqual(result['pacing'], expected_pacing)
|
||||
|
||||
|
||||
class TestCourseDetailSerializer(TestCourseSerializer): # pylint: disable=test-inherits-tests
|
||||
"""
|
||||
|
||||
@@ -52,6 +52,7 @@ class CourseDetailView(DeveloperErrorViewMixin, RetrieveAPIView):
|
||||
* `"string"`: manually set
|
||||
* `"timestamp"`: generated form `start` timestamp
|
||||
* `"empty"`: the start date should not be shown
|
||||
* pacing: Course pacing. Possible values: instructor, self
|
||||
|
||||
Deprecated fields:
|
||||
|
||||
@@ -94,7 +95,8 @@ class CourseDetailView(DeveloperErrorViewMixin, RetrieveAPIView):
|
||||
"overview: "<p>A verbose description of the course.</p>"
|
||||
"start": "2015-07-17T12:00:00Z",
|
||||
"start_display": "July 17, 2015",
|
||||
"start_type": "timestamp"
|
||||
"start_type": "timestamp",
|
||||
"pacing": "instructor"
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user