Merge pull request #26952 from edx/pyupgrade-effort-esi
pyupgrade in enterprise_support
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Tests for effort_estimation transformers."""
|
||||
|
||||
from datetime import timedelta
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from crum import set_current_request
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
@@ -28,7 +28,7 @@ class EnrollmentAttributeOverrideView(FormView):
|
||||
return reverse('admin:enterprise_override_attributes')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(EnrollmentAttributeOverrideView, self).get_context_data(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
context = super().get_context_data(**kwargs)
|
||||
context.update(self._get_admin_context(self.request))
|
||||
return context
|
||||
|
||||
@@ -68,4 +68,4 @@ class EnrollmentAttributeOverrideView(FormView):
|
||||
).format(error_line_numbers=', '.join(error_line_numbers))
|
||||
)
|
||||
|
||||
return super(EnrollmentAttributeOverrideView, self).form_valid(form) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
return super().form_valid(form)
|
||||
|
||||
@@ -58,7 +58,7 @@ class EnterpriseApiException(Exception):
|
||||
"""
|
||||
|
||||
|
||||
class ConsentApiClient(object):
|
||||
class ConsentApiClient:
|
||||
"""
|
||||
Class for producing an Enterprise Consent service API client
|
||||
"""
|
||||
@@ -121,7 +121,7 @@ class ConsentApiClient(object):
|
||||
return response['consent_required']
|
||||
|
||||
|
||||
class EnterpriseServiceClientMixin(object):
|
||||
class EnterpriseServiceClientMixin:
|
||||
"""
|
||||
Class for initializing an Enterprise API clients with service user.
|
||||
"""
|
||||
@@ -132,7 +132,7 @@ class EnterpriseServiceClientMixin(object):
|
||||
Enterprise worker user by default.
|
||||
"""
|
||||
user = User.objects.get(username=settings.ENTERPRISE_SERVICE_WORKER_USERNAME)
|
||||
super(EnterpriseServiceClientMixin, self).__init__(user) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().__init__(user)
|
||||
|
||||
|
||||
class ConsentApiServiceClient(EnterpriseServiceClientMixin, ConsentApiClient):
|
||||
@@ -141,7 +141,7 @@ class ConsentApiServiceClient(EnterpriseServiceClientMixin, ConsentApiClient):
|
||||
"""
|
||||
|
||||
|
||||
class EnterpriseApiClient(object):
|
||||
class EnterpriseApiClient:
|
||||
"""
|
||||
Class for producing an Enterprise service API client.
|
||||
"""
|
||||
@@ -176,8 +176,8 @@ class EnterpriseApiClient(object):
|
||||
endpoint.post(data=data)
|
||||
except (HttpClientError, HttpServerError):
|
||||
message = (
|
||||
u"An error occured while posting EnterpriseCourseEnrollment for user {username} and "
|
||||
u"course run {course_id} (consent_granted value: {consent_granted})"
|
||||
"An error occured while posting EnterpriseCourseEnrollment for user {username} and "
|
||||
"course run {course_id} (consent_granted value: {consent_granted})"
|
||||
).format(
|
||||
username=username,
|
||||
course_id=course_id,
|
||||
@@ -273,7 +273,7 @@ class EnterpriseApiClient(object):
|
||||
response = endpoint().get(**querystring)
|
||||
except (HttpClientError, HttpServerError):
|
||||
LOGGER.exception(
|
||||
u'Failed to get enterprise-learner for user [%s] with client user [%s]. Caller: %s, Request PATH: %s',
|
||||
'Failed to get enterprise-learner for user [%s] with client user [%s]. Caller: %s, Request PATH: %s',
|
||||
user.username,
|
||||
self.user.username,
|
||||
"".join(traceback.format_stack()),
|
||||
@@ -355,7 +355,7 @@ def data_sharing_consent_required(view_func):
|
||||
if consent_url:
|
||||
real_user = getattr(request.user, 'real_user', request.user)
|
||||
LOGGER.info(
|
||||
u'User %s cannot access the course %s because they have not granted consent',
|
||||
'User %s cannot access the course %s because they have not granted consent',
|
||||
real_user,
|
||||
course_id,
|
||||
)
|
||||
@@ -594,7 +594,7 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
|
||||
data sharing permissions before accessing a course.
|
||||
"""
|
||||
LOGGER.info(
|
||||
u"Determining if user [{username}] must consent to data sharing for course [{course_id}]".format(
|
||||
"Determining if user [{username}] must consent to data sharing for course [{course_id}]".format(
|
||||
username=user.username,
|
||||
course_id=course_id
|
||||
)
|
||||
@@ -604,8 +604,8 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
|
||||
data_sharing_consent_needed_cache = TieredCache.get_cached_response(consent_cache_key)
|
||||
if data_sharing_consent_needed_cache.is_found and data_sharing_consent_needed_cache.value == 0:
|
||||
LOGGER.info(
|
||||
u"Consent from user [{username}] is not needed for course [{course_id}]. The DSC cache was checked,"
|
||||
u" and the value was 0.".format(
|
||||
"Consent from user [{username}] is not needed for course [{course_id}]. The DSC cache was checked,"
|
||||
" and the value was 0.".format(
|
||||
username=user.username,
|
||||
course_id=course_id
|
||||
)
|
||||
@@ -616,8 +616,8 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
|
||||
enterprise_learner_details = get_enterprise_learner_data_from_db(user)
|
||||
if not enterprise_learner_details:
|
||||
LOGGER.info(
|
||||
u"Consent from user [{username}] is not needed for course [{course_id}]. The user is not linked to an"
|
||||
u" enterprise.".format(
|
||||
"Consent from user [{username}] is not needed for course [{course_id}]. The user is not linked to an"
|
||||
" enterprise.".format(
|
||||
username=user.username,
|
||||
course_id=course_id
|
||||
)
|
||||
@@ -665,16 +665,16 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
|
||||
|
||||
if consent_needed:
|
||||
LOGGER.info(
|
||||
u"Consent from user [{username}] is needed for course [{course_id}]. The user's current enterprise"
|
||||
u" required data sharing consent, and it has not been given.".format(
|
||||
"Consent from user [{username}] is needed for course [{course_id}]. The user's current enterprise"
|
||||
" required data sharing consent, and it has not been given.".format(
|
||||
username=user.username,
|
||||
course_id=course_id
|
||||
)
|
||||
)
|
||||
else:
|
||||
LOGGER.info(
|
||||
u"Consent from user [{username}] is not needed for course [{course_id}]. The user's current enterprise "
|
||||
u"does not require data sharing consent.".format(
|
||||
"Consent from user [{username}] is not needed for course [{course_id}]. The user's current enterprise "
|
||||
"does not require data sharing consent.".format(
|
||||
username=user.username,
|
||||
course_id=course_id
|
||||
)
|
||||
@@ -727,7 +727,7 @@ def get_enterprise_consent_url(request, course_id, user=None, return_to=None, en
|
||||
user = user or request.user
|
||||
|
||||
LOGGER.info(
|
||||
u'Getting enterprise consent url for user [{username}] and course [{course_id}].'.format(
|
||||
'Getting enterprise consent url for user [{username}] and course [{course_id}].'.format(
|
||||
username=user.username,
|
||||
course_id=course_id
|
||||
)
|
||||
@@ -755,7 +755,7 @@ def get_enterprise_consent_url(request, course_id, user=None, return_to=None, en
|
||||
}
|
||||
querystring = urlencode(url_params)
|
||||
full_url = reverse('grant_data_sharing_permissions') + '?' + querystring
|
||||
LOGGER.info(u'Redirecting to %s to complete data sharing consent', full_url)
|
||||
LOGGER.info('Redirecting to %s to complete data sharing consent', full_url)
|
||||
return full_url
|
||||
|
||||
|
||||
@@ -844,7 +844,7 @@ def get_consent_notification_data(enterprise_customer):
|
||||
message_template = consent_page.declined_notification_message
|
||||
except DataSharingConsentTextOverrides.DoesNotExist:
|
||||
LOGGER.info(
|
||||
u"DataSharingConsentPage object doesn't exit for {enterprise_customer_name}".format(
|
||||
"DataSharingConsentPage object doesn't exit for {enterprise_customer_name}".format(
|
||||
enterprise_customer_name=enterprise_customer['name']
|
||||
)
|
||||
)
|
||||
@@ -891,12 +891,12 @@ def get_dashboard_consent_notification(request, user, course_enrollments):
|
||||
title_template, message_template = get_consent_notification_data(enterprise_customer)
|
||||
if not title_template:
|
||||
title_template = _(
|
||||
u'Enrollment in {course_title} was not complete.'
|
||||
'Enrollment in {course_title} was not complete.'
|
||||
)
|
||||
if not message_template:
|
||||
message_template = _(
|
||||
'If you have concerns about sharing your data, please contact your administrator '
|
||||
u'at {enterprise_customer_name}.'
|
||||
'at {enterprise_customer_name}.'
|
||||
)
|
||||
|
||||
title = title_template.format(
|
||||
|
||||
@@ -66,9 +66,9 @@ def update_dsc_cache_on_enterprise_customer_update(sender, instance, **kwargs):
|
||||
new_value = instance.enable_data_sharing_consent
|
||||
old_value = old_instance.enable_data_sharing_consent
|
||||
if new_value != old_value:
|
||||
kwargs = {'enterprise_customer_uuid': six.text_type(instance.uuid)}
|
||||
kwargs = {'enterprise_customer_uuid': str(instance.uuid)}
|
||||
result = clear_enterprise_customer_data_consent_share_cache.apply_async(kwargs=kwargs)
|
||||
log.info(u"DSC: Created {task_name}[{task_id}] with arguments {kwargs}".format(
|
||||
log.info("DSC: Created {task_name}[{task_id}] with arguments {kwargs}".format(
|
||||
task_name=clear_enterprise_customer_data_consent_share_cache.name,
|
||||
task_id=result.task_id,
|
||||
kwargs=kwargs,
|
||||
@@ -82,8 +82,8 @@ def handle_enterprise_learner_passing_grade(sender, user, course_id, **kwargs):
|
||||
"""
|
||||
if enterprise_enabled() and is_enterprise_learner(user):
|
||||
kwargs = {
|
||||
'username': six.text_type(user.username),
|
||||
'course_run_id': six.text_type(course_id)
|
||||
'username': str(user.username),
|
||||
'course_run_id': str(course_id)
|
||||
}
|
||||
|
||||
transmit_single_learner_data.apply_async(kwargs=kwargs)
|
||||
@@ -125,7 +125,7 @@ def refund_order_voucher(sender, course_enrollment, skip_refund=False, **kwargs)
|
||||
client = ecommerce_api_client(service_user)
|
||||
order_number = course_enrollment.get_order_attribute_value('order_number')
|
||||
if order_number:
|
||||
error_message = u"Encountered {} from ecommerce while creating refund voucher. Order={}, enrollment={}, user={}"
|
||||
error_message = "Encountered {} from ecommerce while creating refund voucher. Order={}, enrollment={}, user={}"
|
||||
try:
|
||||
client.enterprise.coupons.create_refunded_voucher.post({"order": order_number})
|
||||
except HttpClientError as ex:
|
||||
|
||||
@@ -14,7 +14,7 @@ from openedx.features.enterprise_support.utils import clear_data_consent_share_c
|
||||
log = logging.getLogger('edx.celery.task')
|
||||
|
||||
|
||||
@shared_task(name=u'openedx.features.enterprise_support.tasks.clear_enterprise_customer_data_consent_share_cache')
|
||||
@shared_task(name='openedx.features.enterprise_support.tasks.clear_enterprise_customer_data_consent_share_cache')
|
||||
@set_code_owner_attribute
|
||||
def clear_enterprise_customer_data_consent_share_cache(enterprise_customer_uuid):
|
||||
"""
|
||||
@@ -25,7 +25,7 @@ def clear_enterprise_customer_data_consent_share_cache(enterprise_customer_uuid)
|
||||
)
|
||||
count = enterprise_course_enrollments.count()
|
||||
log.info(
|
||||
u'Stated Clearing {count} data_sharing_consent_needed cache for enterprise customer {uuid}'.format(
|
||||
'Stated Clearing {count} data_sharing_consent_needed cache for enterprise customer {uuid}'.format(
|
||||
count=count,
|
||||
uuid=enterprise_customer_uuid,
|
||||
)
|
||||
@@ -35,6 +35,6 @@ def clear_enterprise_customer_data_consent_share_cache(enterprise_customer_uuid)
|
||||
enrollment.enterprise_customer_user.user_id,
|
||||
enrollment.course_id
|
||||
)
|
||||
log.info(u'Ended Clearing data_sharing_consent_needed cache for enterprise customer {uuid}'.format(
|
||||
log.info('Ended Clearing data_sharing_consent_needed cache for enterprise customer {uuid}'.format(
|
||||
uuid=enterprise_customer_uuid,
|
||||
))
|
||||
|
||||
@@ -28,7 +28,7 @@ class EnterpriseCustomerFactory(factory.django.DjangoModelFactory):
|
||||
parameters for EnterpriseCustomer constructor.
|
||||
"""
|
||||
|
||||
class Meta(object):
|
||||
class Meta:
|
||||
"""
|
||||
Meta for EnterpriseCustomerFactory.
|
||||
"""
|
||||
@@ -52,7 +52,7 @@ class EnterpriseCustomerUserFactory(factory.django.DjangoModelFactory):
|
||||
parameters for EnterpriseCustomerUser constructor.
|
||||
"""
|
||||
|
||||
class Meta(object):
|
||||
class Meta:
|
||||
"""
|
||||
Meta for EnterpriseCustomerFactory.
|
||||
"""
|
||||
@@ -70,7 +70,7 @@ class EnterpriseCourseEnrollmentFactory(factory.django.DjangoModelFactory):
|
||||
Creates an instance of EnterpriseCourseEnrollment with minimal boilerplate.
|
||||
"""
|
||||
|
||||
class Meta(object):
|
||||
class Meta:
|
||||
"""
|
||||
Meta for EnterpriseCourseEnrollmentFactory.
|
||||
"""
|
||||
@@ -88,7 +88,7 @@ class EnterpriseCustomerBrandingConfigurationFactory(factory.django.DjangoModelF
|
||||
Creates an instance of EnterpriseCustomerBrandingConfiguration with minimal boilerplate.
|
||||
"""
|
||||
|
||||
class Meta(object):
|
||||
class Meta:
|
||||
"""
|
||||
Meta for EnterpriseCustomerBrandingConfigurationFactory.
|
||||
"""
|
||||
@@ -106,7 +106,7 @@ class EnterpriseCustomerIdentityProviderFactory(factory.django.DjangoModelFactor
|
||||
EnterpriseCustomerIdentityProvider factory.
|
||||
"""
|
||||
|
||||
class Meta(object):
|
||||
class Meta:
|
||||
"""
|
||||
Meta for EnterpriseCustomerIdentityProviderFactory.
|
||||
"""
|
||||
|
||||
@@ -5,7 +5,7 @@ Mixins for the EnterpriseApiClient.
|
||||
|
||||
import json
|
||||
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import httpretty
|
||||
from django.conf import settings
|
||||
@@ -15,7 +15,7 @@ from django.urls import reverse
|
||||
from openedx.features.enterprise_support.tests import FAKE_ENTERPRISE_CUSTOMER
|
||||
|
||||
|
||||
class EnterpriseServiceMockMixin(object):
|
||||
class EnterpriseServiceMockMixin:
|
||||
"""
|
||||
Mocks for the Enterprise service responses.
|
||||
"""
|
||||
@@ -23,13 +23,13 @@ class EnterpriseServiceMockMixin(object):
|
||||
consent_url = '{}{}'.format(settings.ENTERPRISE_CONSENT_API_URL, 'data_sharing_consent')
|
||||
|
||||
def setUp(self):
|
||||
super(EnterpriseServiceMockMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
cache.clear()
|
||||
|
||||
@staticmethod
|
||||
def get_enterprise_url(path):
|
||||
"""Return a URL to the configured Enterprise API. """
|
||||
return '{}{}/'.format(settings.ENTERPRISE_API_URL, path)
|
||||
return f'{settings.ENTERPRISE_API_URL}{path}/'
|
||||
|
||||
def mock_get_enterprise_customer(self, uuid, response, status):
|
||||
"""
|
||||
|
||||
@@ -24,7 +24,7 @@ class EnrollmentAttributeOverrideViewTest(ModuleStoreTestCase):
|
||||
|
||||
def setUp(self):
|
||||
""" Test case setup """
|
||||
super(EnrollmentAttributeOverrideViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
|
||||
self.client = Client()
|
||||
user = AdminFactory()
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""
|
||||
Test the enterprise support APIs.
|
||||
"""
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import httpretty
|
||||
import mock
|
||||
import pytest
|
||||
from consent.models import DataSharingConsent
|
||||
from django.conf import settings
|
||||
@@ -21,7 +22,6 @@ from common.djangoapps.student.tests.factories import UserFactory
|
||||
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
|
||||
from openedx.features.enterprise_support.api import (
|
||||
activate_learner_enterprise,
|
||||
_CACHE_MISS,
|
||||
ENTERPRISE_CUSTOMER_KEY_NAME,
|
||||
ConsentApiClient,
|
||||
@@ -29,6 +29,7 @@ from openedx.features.enterprise_support.api import (
|
||||
EnterpriseApiClient,
|
||||
EnterpriseApiException,
|
||||
EnterpriseApiServiceClient,
|
||||
activate_learner_enterprise,
|
||||
add_enterprise_customer_to_session,
|
||||
consent_needed_for_course,
|
||||
data_sharing_consent_required,
|
||||
@@ -80,7 +81,7 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
|
||||
email='ent_worker@example.com',
|
||||
password='password123',
|
||||
)
|
||||
super(TestEnterpriseApi, cls).setUpTestData()
|
||||
super().setUpTestData()
|
||||
|
||||
def _assert_api_service_client(self, api_client, mocked_jwt_builder):
|
||||
"""
|
||||
@@ -659,7 +660,7 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
|
||||
'course_id': ['course-v1:edX+DemoX+Demo_Course'],
|
||||
'failure_url': ['http://localhost:8000/dashboard?consent_failed=course-v1%3AedX%2BDemoX%2BDemo_Course'],
|
||||
'enterprise_customer_uuid': ['cf246b88-d5f6-4908-a522-fc307e0b0c59'],
|
||||
'next': ['http://localhost:8000{}'.format(expected_path)]
|
||||
'next': [f'http://localhost:8000{expected_path}']
|
||||
}
|
||||
|
||||
actual_url = get_enterprise_consent_url(request_mock, course_id, return_to=return_to)
|
||||
|
||||
@@ -3,12 +3,14 @@ Tests for logout for enterprise flow
|
||||
"""
|
||||
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from common.djangoapps.util.testing import UrlResetMixin
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
|
||||
from openedx.features.enterprise_support.api import enterprise_enabled
|
||||
from openedx.features.enterprise_support.tests import (
|
||||
@@ -17,8 +19,6 @@ from openedx.features.enterprise_support.tests import (
|
||||
factories
|
||||
)
|
||||
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from common.djangoapps.util.testing import UrlResetMixin
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@@ -28,7 +28,7 @@ class EnterpriseLogoutTests(EnterpriseServiceMockMixin, CacheIsolationTestCase,
|
||||
""" Tests for the enterprise logout functionality. """
|
||||
|
||||
def setUp(self):
|
||||
super(EnterpriseLogoutTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.user = UserFactory()
|
||||
|
||||
self.enterprise_customer = FAKE_ENTERPRISE_CUSTOMER
|
||||
|
||||
@@ -3,21 +3,23 @@
|
||||
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
import ddt
|
||||
from django.test.utils import override_settings
|
||||
from django.utils.timezone import now
|
||||
from edx_django_utils.cache import TieredCache
|
||||
from mock import patch
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from slumber.exceptions import HttpClientError, HttpServerError
|
||||
from testfixtures import LogCapture
|
||||
|
||||
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
|
||||
from common.djangoapps.student.models import CourseEnrollmentAttribute
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from lms.djangoapps.certificates.signals import listen_for_passing_grade
|
||||
from openedx.core.djangoapps.commerce.utils import ECOMMERCE_DATE_FORMAT
|
||||
from openedx.core.djangoapps.credit.tests.test_api import TEST_ECOMMERCE_WORKER
|
||||
from openedx.core.djangoapps.signals.signals import COURSE_GRADE_NOW_PASSED, COURSE_ASSESSMENT_GRADE_CHANGED
|
||||
from openedx.core.djangoapps.signals.signals import COURSE_ASSESSMENT_GRADE_CHANGED, COURSE_GRADE_NOW_PASSED
|
||||
from openedx.features.enterprise_support.tests import FEATURES_WITH_ENTERPRISE_ENABLED
|
||||
from openedx.features.enterprise_support.tests.factories import (
|
||||
EnterpriseCourseEnrollmentFactory,
|
||||
@@ -25,8 +27,6 @@ from openedx.features.enterprise_support.tests.factories import (
|
||||
EnterpriseCustomerUserFactory
|
||||
)
|
||||
from openedx.features.enterprise_support.utils import get_data_consent_share_cache_key
|
||||
from common.djangoapps.student.models import CourseEnrollmentAttribute
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
@@ -50,7 +50,7 @@ class EnterpriseSupportSignals(SharedModuleStoreTestCase):
|
||||
self.user = UserFactory.create(username='test', email=TEST_EMAIL)
|
||||
self.course_id = 'course-v1:edX+DemoX+Demo_Course'
|
||||
self.enterprise_customer = EnterpriseCustomerFactory()
|
||||
super(EnterpriseSupportSignals, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
|
||||
@staticmethod
|
||||
def _create_dsc_cache(user_id, course_id):
|
||||
|
||||
@@ -4,15 +4,16 @@ Test the enterprise support utils.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import NoReverseMatch
|
||||
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from openedx.features.enterprise_support.tests import FEATURES_WITH_ENTERPRISE_ENABLED
|
||||
from openedx.features.enterprise_support.tests.factories import (
|
||||
@@ -36,9 +37,8 @@ from openedx.features.enterprise_support.utils import (
|
||||
is_enterprise_learner,
|
||||
update_account_settings_context_for_enterprise,
|
||||
update_logistration_context_for_enterprise,
|
||||
update_third_party_auth_context_for_enterprise,
|
||||
update_third_party_auth_context_for_enterprise
|
||||
)
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@@ -52,7 +52,7 @@ class TestEnterpriseUtils(TestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.user = UserFactory.create(password='password')
|
||||
super(TestEnterpriseUtils, cls).setUpTestData()
|
||||
super().setUpTestData()
|
||||
|
||||
@mock.patch('openedx.features.enterprise_support.utils.get_cache_key')
|
||||
def test_get_data_consent_share_cache_key(self, mock_get_cache_key):
|
||||
|
||||
@@ -165,10 +165,10 @@ def update_third_party_auth_context_for_enterprise(request, context, enterprise_
|
||||
"""
|
||||
if context['data']['third_party_auth']['errorMessage']:
|
||||
context['data']['third_party_auth']['errorMessage'] = Text(_(
|
||||
u'We are sorry, you are not authorized to access {platform_name} via this channel. '
|
||||
u'Please contact your learning administrator or manager in order to access {platform_name}.'
|
||||
u'{line_break}{line_break}'
|
||||
u'Error Details:{line_break}{error_message}')
|
||||
'We are sorry, you are not authorized to access {platform_name} via this channel. '
|
||||
'Please contact your learning administrator or manager in order to access {platform_name}.'
|
||||
'{line_break}{line_break}'
|
||||
'Error Details:{line_break}{error_message}')
|
||||
).format(
|
||||
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
|
||||
error_message=context['data']['third_party_auth']['errorMessage'],
|
||||
|
||||
Reference in New Issue
Block a user