Skip to content

Commit

Permalink
Merge pull request #365 from appsembler/john/fix-enrollment-data-seri…
Browse files Browse the repository at this point in the history
…alizer

Serializer Bug fix and version bump to 0.4.dev10
  • Loading branch information
johnbaldwin authored Jun 7, 2021
2 parents 44c0954 + 8a19043 commit 519b6fb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Reporting and data retrieval app for `Open edX <https://open.edx.org/>`__.

.. _notice_section:

TBD Q1 2021 - Figures release 0.4 "Official"
TBD Q3 2021 - Figures release 0.4 "Official"
============================================

**Most recent release**: "0.4.dev9" on June 2, 2021
**Most recent release**: "0.4.dev10" on June 6, 2021

Figures is iterating through "0.4.dev" development releases on the way to
an official 0.4 release.
Expand Down
5 changes: 2 additions & 3 deletions figures/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,14 +892,13 @@ class EnrollmentDataSerializer(serializers.ModelSerializer):
This serializer note not identify the learner. It is used in
LearnerMetricsSerializer
"""
date_enrolled = serializers.DateTimeField(format="%Y-%m-%d")
date_enrolled = serializers.DateField(format="%Y-%m-%d")
progress_details = serializers.SerializerMethodField()

class Meta:
model = EnrollmentData
fields = [
'id', 'course_id', 'date_enrolled', 'date_enrolled',
'is_enrolled', 'is_completed',
'id', 'course_id', 'date_enrolled', 'is_enrolled', 'is_completed',
'progress_percent', 'progress_details',
]
read_only_fields = fields
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name='Figures',
version='0.4.dev9',
version='0.4.dev10',
packages=find_packages(),
include_package_data=True,
license='MIT',
Expand Down
25 changes: 25 additions & 0 deletions tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
CourseEnrollmentSerializer,
CourseMauMetricsSerializer,
CourseMauLiveMetricsSerializer,
EnrollmentDataSerializer,
GeneralCourseDataSerializer,
GeneralUserDataSerializer,
LearnerCourseDetailsSerializer,
Expand All @@ -46,6 +47,7 @@
CourseEnrollmentFactory,
CourseMauMetricsFactory,
CourseOverviewFactory,
EnrollmentDataFactory,
GeneratedCertificateFactory,
LearnerCourseGradeMetricsFactory,
SiteDailyMetricsFactory,
Expand Down Expand Up @@ -322,6 +324,29 @@ def test_save(self):
assert SiteDailyMetrics.objects.count() == 2


@pytest.mark.django_db
class TestEnrollmentDataSerializer(object):
@pytest.fixture(autouse=True)
def setup(self, db):
self.enrollment_data = EnrollmentDataFactory()
self.expected_fields = [
'id', 'course_id', 'date_enrolled', 'is_enrolled', 'is_completed',
'progress_percent', 'progress_details',
]
self.date_enrolled_format = '%Y-%m-%d'

def test_serialize(self):
"""Test Serializing EnrollmentData model with EnrollmentDataSerializer
Minimal test after bug fix for https://github.com/appsembler/figures/issues/364
"""
expected_date_enrolled = self.enrollment_data.date_enrolled.strftime(
self.date_enrolled_format)
serializer = EnrollmentDataSerializer(self.enrollment_data)
assert set(serializer.data.keys()) == set(self.expected_fields)
assert serializer.data['date_enrolled'] == expected_date_enrolled


@pytest.mark.django_db
class TestGeneralCourseDataSerializer(object):
'''
Expand Down

0 comments on commit 519b6fb

Please sign in to comment.