|
14 | 14 |
|
15 | 15 | from django.conf import settings |
16 | 16 | from django.core import management |
| 17 | +from django.test import override_settings |
17 | 18 |
|
18 | 19 | from analyticsdataserver.tests import TestCaseWithAuthentication |
19 | 20 | from analytics_data_api.constants import engagement_events |
@@ -769,6 +770,29 @@ def test_cohorts(self, course_id, cohorts): |
769 | 770 | ) |
770 | 771 | self.assert_response_matches(self._get(course_id), 200, expected) |
771 | 772 |
|
| 773 | + @ddt.data( |
| 774 | + (CourseSamples.course_ids[0], [], {}), |
| 775 | + (CourseSamples.course_ids[1], ['Yellow'], {'Yellow': 1}), |
| 776 | + (CourseSamples.course_ids[1], ['Yellow', 'Green'], {'Yellow': 1, 'Green': 1}), |
| 777 | + (CourseSamples.course_ids[0], ['Red', 'Red', 'yellow team', 'green'], {'Red': 2, 'green': 1}), |
| 778 | + ) |
| 779 | + @ddt.unpack |
| 780 | + @override_settings(AGGREGATE_PAGE_SIZE=2) |
| 781 | + def test_cohorts_page_size(self, course_id, cohorts, expected_cohorts): |
| 782 | + """ Ensure that the AGGREGATE_PAGE_SIZE sets the max number of cohorts returned.""" |
| 783 | + |
| 784 | + self.create_learners([ |
| 785 | + {'username': 'user_{}'.format(i), 'course_id': course_id, 'cohort': cohort} |
| 786 | + for i, cohort in enumerate(cohorts) |
| 787 | + ]) |
| 788 | + expected = self.get_expected_json( |
| 789 | + course_id=course_id, |
| 790 | + segments={'disengaging': 0, 'struggling': 0, 'highly_engaged': 0, 'inactive': 0, 'unenrolled': 0}, |
| 791 | + enrollment_modes={'honor': len(cohorts)} if cohorts else {}, |
| 792 | + cohorts=expected_cohorts, |
| 793 | + ) |
| 794 | + self.assert_response_matches(self._get(course_id), 200, expected) |
| 795 | + |
772 | 796 | @property |
773 | 797 | def empty_engagement_ranges(self): |
774 | 798 | """ Returns the engagement ranges where all fields are set to None. """ |
|
0 commit comments