|
22 | 22 | from django.http import HttpRequest, HttpResponse
|
23 | 23 | from django.test import RequestFactory, TestCase
|
24 | 24 | from django.test.client import MULTIPART_CONTENT
|
| 25 | +from django.test.utils import override_settings |
25 | 26 | from django.urls import reverse as django_reverse
|
26 | 27 | from django.utils.translation import gettext as _
|
27 | 28 | from edx_when.api import get_dates_for_course, get_overrides_for_user, set_date_for_block
|
@@ -2626,6 +2627,23 @@ def test_get_students_features(self):
|
2626 | 2627 | assert student_json['city'] == student.profile.city
|
2627 | 2628 | assert student_json['country'] == ''
|
2628 | 2629 |
|
| 2630 | + @ddt.data(True, False) |
| 2631 | + def test_get_students_features_private_fields(self, show_private_fields): |
| 2632 | + """ |
| 2633 | + Test that the get_students_features returns the expected private fields |
| 2634 | + """ |
| 2635 | + with override_settings(FEATURES={'SHOW_PRIVATE_FIELDS_IN_PROFILE_INFORMATION_REPORT': show_private_fields}): |
| 2636 | + url = reverse('get_students_features', kwargs={'course_id': str(self.course.id)}) |
| 2637 | + response = self.client.post(url, {}) |
| 2638 | + res_json = json.loads(response.content.decode('utf-8')) |
| 2639 | + |
| 2640 | + assert 'students' in res_json |
| 2641 | + for student in res_json['students']: |
| 2642 | + if show_private_fields: |
| 2643 | + assert 'year_of_birth' in student |
| 2644 | + else: |
| 2645 | + assert 'year_of_birth' not in student |
| 2646 | + |
2629 | 2647 | @ddt.data(True, False)
|
2630 | 2648 | def test_get_students_features_cohorted(self, is_cohorted):
|
2631 | 2649 | """
|
|
0 commit comments