def create_course_enrollments_context(<EOL>self,<EOL>user_exists,<EOL>lms_user_id,<EOL>tpa_user_id,<EOL>user_email,<EOL>mock_tpa_client,<EOL>mock_enrollment_client,<EOL>course_enrollment,<EOL>mock_catalog_contains_course,<EOL>course_in_catalog,<EOL>enable_autocohorting=False<EOL>):
enterprise_customer = factories.EnterpriseCustomerFactory(<EOL>uuid=FAKE_UUIDS[<NUM_LIT:0>],<EOL>name="<STR_LIT>",<EOL>enable_autocohorting=enable_autocohorting<EOL>)<EOL>permission = Permission.objects.get(name='<STR_LIT>')<EOL>self.user.user_permissions.add(permission)<EOL>user = None<EOL>if user_exists:<EOL><INDENT>if lms_user_id:<EOL><INDENT>user = factories.UserFactory(id=lms_user_id)<EOL><DEDENT>elif tpa_user_id:<EOL><INDENT>user = factories.UserFactory(username=tpa_user_id)<EOL><DEDENT>elif user_email:<EOL><INDENT>user = factories.UserFactory(email=user_email)<EOL><DEDENT>factories.EnterpriseCustomerUserFactory(<EOL>user_id=user.id,<EOL>enterprise_customer=enterprise_customer,<EOL>)<EOL><DEDENT>if tpa_user_id:<EOL><INDENT>mock_tpa_client.return_value = mock.Mock()<EOL>mock_tpa_client.return_value.get_username_from_remote_id = mock.Mock()<EOL>mock_tpa_client.return_value.get_username_from_remote_id.return_value = tpa_user_id<EOL><DEDENT>mock_enrollment_client.return_value = mock.Mock(<EOL>get_course_enrollment=mock.Mock(return_value=course_enrollment),<EOL>enroll_user_in_course=mock.Mock()<EOL>)<EOL>mock_catalog_contains_course.return_value = course_in_catalog<EOL>return enterprise_customer, user<EOL>
Set up for tests that call the enterprise customer course enrollments detail route.