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:
Christopher Pappas
2019-09-04 18:39:16 -04:00
parent 1c4a645d4c
commit 5f510a8dd5
3 changed files with 14 additions and 2 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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)