fix: Add missing PII annotation and fix amnesty warnings (#27917)
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
"""
|
||||
Demographics models
|
||||
"""
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from model_utils.models import TimeStampedModel
|
||||
@@ -11,6 +14,8 @@ class UserDemographics(TimeStampedModel):
|
||||
"""
|
||||
A Users Demographics platform related data in support of the Demographics
|
||||
IDA and features
|
||||
|
||||
.. no_pii:
|
||||
"""
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
show_call_to_action = models.BooleanField(default=True)
|
||||
|
||||
@@ -21,7 +21,10 @@ class DemographicsStatusView(APIView):
|
||||
authentication_classes = (JwtAuthentication, SessionAuthentication)
|
||||
permission_classes = (permissions.IsAuthenticated, )
|
||||
|
||||
def _response_context(self, user, user_demographics=None): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
def _response_context(self, user, user_demographics=None):
|
||||
"""
|
||||
Determine whether the user should be shown demographics collection fields and the demographics call to action.
|
||||
"""
|
||||
if user_demographics:
|
||||
show_call_to_action = user_demographics.show_call_to_action
|
||||
else:
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
"""
|
||||
Test status utilities
|
||||
"""
|
||||
from unittest import TestCase
|
||||
from unittest import mock
|
||||
|
||||
from django.conf import settings
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from pytest import mark
|
||||
from unittest import TestCase # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
|
||||
from opaque_keys.edx.keys import CourseKey # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase, TEST_DATA_SPLIT_MODULESTORE
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
from openedx.core.djangoapps.catalog.tests.factories import (
|
||||
ProgramFactory,
|
||||
)
|
||||
from openedx.features.enterprise_support.tests.factories import EnterpriseCustomerUserFactory
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from openedx.features.enterprise_support.tests.factories import EnterpriseCustomerUserFactory
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase, TEST_DATA_SPLIT_MODULESTORE
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
if settings.ROOT_URLCONF == 'lms.urls':
|
||||
from openedx.core.djangoapps.demographics.api.status import show_user_demographics, show_call_to_action_for_user
|
||||
@@ -30,7 +29,10 @@ MICROBACHELORS = 'microbachelors'
|
||||
|
||||
@skip_unless_lms
|
||||
@mock.patch('openedx.core.djangoapps.programs.utils.get_programs_by_type')
|
||||
class TestShowDemographics(SharedModuleStoreTestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
class TestShowDemographics(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Tests for whether the demographics collection fields should be shown
|
||||
"""
|
||||
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
|
||||
|
||||
@classmethod
|
||||
@@ -57,7 +59,10 @@ class TestShowDemographics(SharedModuleStoreTestCase): # lint-amnesty, pylint:
|
||||
|
||||
@skip_unless_lms
|
||||
@mark.django_db
|
||||
class TestShowCallToAction(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
class TestShowCallToAction(TestCase):
|
||||
"""
|
||||
Tests for whether the demographics call to action should be shown
|
||||
"""
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.user = UserFactory()
|
||||
|
||||
Reference in New Issue
Block a user