This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AN-8555 Add programs endpoint (#166)
* Add programs endpoint & programs list to summaries * Exclude programs array from the course_summaries * Add/fix tests, program field exclude option * Refactor common list view code into APIListView * Fix some pylint errors * Fix bad import * Use assertListEqual and sort lists first * Refactor common test code into mixin * Increase test coverage (test add_programs) * Add documentation for programs query arg * Address PR comments
- Loading branch information
Showing
12 changed files
with
560 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from datetime import date | ||
from django.test import TestCase | ||
from django_dynamic_fixture import G | ||
|
||
from analytics_data_api.v0 import models as api_models, serializers as api_serializers | ||
|
||
|
||
class TestSerializer(api_serializers.CourseEnrollmentDailySerializer, api_serializers.DynamicFieldsModelSerializer): | ||
pass | ||
|
||
|
||
class DynamicFieldsModelSerializerTests(TestCase): | ||
def test_fields(self): | ||
now = date.today() | ||
instance = G(api_models.CourseEnrollmentDaily, course_id='1', count=1, date=now) | ||
serialized = TestSerializer(instance) | ||
self.assertListEqual(serialized.data.keys(), ['course_id', 'date', 'count', 'created']) | ||
|
||
instance = G(api_models.CourseEnrollmentDaily, course_id='2', count=1, date=now) | ||
serialized = TestSerializer(instance, fields=('course_id',)) | ||
self.assertListEqual(serialized.data.keys(), ['course_id']) | ||
|
||
def test_exclude(self): | ||
now = date.today() | ||
instance = G(api_models.CourseEnrollmentDaily, course_id='3', count=1, date=now) | ||
serialized = TestSerializer(instance, exclude=('course_id',)) | ||
self.assertListEqual(serialized.data.keys(), ['date', 'count', 'created']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.