Merge pull request #17969 from edx/uman/enterprise-middleware

[ENT-962] Add Enterprise middleware that injects customer data.
This commit is contained in:
Uman Shahzad
2018-04-21 09:55:46 +05:00
committed by GitHub
14 changed files with 243 additions and 86 deletions

View File

@@ -33,6 +33,7 @@ from openedx.core.djangoapps.embargo.test_utils import restrict_course
from openedx.core.djangoapps.user_api.models import UserOrgTag
from openedx.core.lib.django_test_client_utils import get_absolute_url
from openedx.core.lib.token_utils import JwtBuilder
from openedx.features.enterprise_support.tests import FAKE_ENTERPRISE_CUSTOMER
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
from student.models import CourseEnrollment
from student.roles import CourseStaffRole
@@ -932,7 +933,8 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente
@httpretty.activate
@override_settings(ENTERPRISE_SERVICE_WORKER_USERNAME='enterprise_worker',
FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True))
def test_enterprise_course_enrollment_with_ec_uuid(self):
@patch('openedx.features.enterprise_support.api.enterprise_customer_from_api')
def test_enterprise_course_enrollment_with_ec_uuid(self, mock_enterprise_customer_from_api):
"""Verify that the enrollment completes when the EnterpriseCourseEnrollment creation succeeds. """
UserFactory.create(
username='enterprise_worker',
@@ -949,6 +951,7 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente
'course_id': unicode(self.course.id),
'ec_uuid': 'this-is-a-real-uuid'
}
mock_enterprise_customer_from_api.return_value = FAKE_ENTERPRISE_CUSTOMER
self.mock_enterprise_course_enrollment_post_api()
self.mock_consent_missing(**consent_kwargs)
self.mock_consent_post(**consent_kwargs)

View File

@@ -454,8 +454,8 @@ def submit_feedback(request):
success = False
context = get_feedback_form_context(request)
#Update the tag info with 'enterprise_learner' if the user belongs to an enterprise customer.
enterprise_learner_data = enterprise_api.get_enterprise_learner_data(site=request.site, user=request.user)
# Update the tag info with 'enterprise_learner' if the user belongs to an enterprise customer.
enterprise_learner_data = enterprise_api.get_enterprise_learner_data(user=request.user)
if enterprise_learner_data:
context["tags"]["learner_type"] = "enterprise_learner"