Updating course overview serializer to return string data for has_ended and has_started, and not a bound method
Oops meant this to be a bool and not a string type Had to add a start and end date for the course overview test fixture for tests to pass
This commit is contained in:
@@ -19,7 +19,7 @@ class CourseOverviewBaseSerializer(serializers.ModelSerializer):
|
||||
def to_representation(self, instance):
|
||||
representation = super(CourseOverviewBaseSerializer, self).to_representation(instance)
|
||||
representation['display_name_with_default'] = instance.display_name_with_default
|
||||
representation['has_started'] = instance.has_started
|
||||
representation['has_ended'] = instance.has_ended
|
||||
representation['has_started'] = instance.has_started()
|
||||
representation['has_ended'] = instance.has_ended()
|
||||
representation['pacing'] = instance.pacing
|
||||
return representation
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
import json
|
||||
|
||||
import factory
|
||||
@@ -35,3 +36,11 @@ class CourseOverviewFactory(DjangoModelFactory):
|
||||
@factory.lazy_attribute
|
||||
def display_name(self):
|
||||
return "{} Course".format(self.id)
|
||||
|
||||
@factory.lazy_attribute
|
||||
def start(self):
|
||||
return datetime.now()
|
||||
|
||||
@factory.lazy_attribute
|
||||
def end(self):
|
||||
return datetime.now() + timedelta(30)
|
||||
|
||||
@@ -35,3 +35,6 @@ class TestCourseOverviewSerializer(TestCase):
|
||||
]
|
||||
for field in fields:
|
||||
assert field in data
|
||||
|
||||
assert isinstance(data['has_started'], bool)
|
||||
assert isinstance(data['has_ended'], bool)
|
||||
|
||||
Reference in New Issue
Block a user