diff --git a/common/djangoapps/enrollment/tests/test_views.py b/common/djangoapps/enrollment/tests/test_views.py index 56db96c35f8263d7a7d606af936628f1fdf5fb0a..ac77ab6883b4159925a572a740971cee680f20dd 100644 --- a/common/djangoapps/enrollment/tests/test_views.py +++ b/common/djangoapps/enrollment/tests/test_views.py @@ -924,8 +924,8 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente self.assertEqual(course_mode, updated_mode) @httpretty.activate - @override_settings(ENTERPRISE_SERVICE_WORKER_USERNAME='enterprise_worker') - @override_settings(ENABLE_ENTERPRISE_INTEGRATION=True) + @override_settings(ENTERPRISE_SERVICE_WORKER_USERNAME='enterprise_worker', + FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True)) def test_enterprise_course_enrollment_with_ec_uuid(self): """Verify that the enrollment completes when the EnterpriseCourseEnrollment creation succeeds. """ UserFactory.create( diff --git a/common/djangoapps/util/tests/test_submit_feedback.py b/common/djangoapps/util/tests/test_submit_feedback.py index 2f963dfc94d744c2f615de0356c82e04d0dd81db..26a396a86631a14a99f9f4a1e64e96574b407bfd 100644 --- a/common/djangoapps/util/tests/test_submit_feedback.py +++ b/common/djangoapps/util/tests/test_submit_feedback.py @@ -52,7 +52,6 @@ def fake_support_backend_values(name, default=None): # pylint: disable=unused-a ZENDESK_USER="dummy", ZENDESK_API_KEY="dummy", ZENDESK_CUSTOM_FIELDS={}, - ENABLE_ENTERPRISE_INTEGRATION=False ) @mock.patch("util.views.dog_stats_api") @mock.patch("util.views._ZendeskApi", autospec=True) @@ -463,7 +462,8 @@ class SubmitFeedbackTest(EnterpriseServiceMockMixin, TestCase): ("course-v1:testOrg+testCourseNumber+testCourseRun", False), ) @unpack - @override_settings(ZENDESK_CUSTOM_FIELDS=TEST_ZENDESK_CUSTOM_FIELD_CONFIG, ENABLE_ENTERPRISE_INTEGRATION=True) + @override_settings(ZENDESK_CUSTOM_FIELDS=TEST_ZENDESK_CUSTOM_FIELD_CONFIG) + @mock.patch.dict("django.conf.settings.FEATURES", dict(ENABLE_ENTERPRISE_INTEGRATION=True)) def test_valid_request_auth_user_with_enterprise_info(self, course_id, enrolled, zendesk_mock_class, datadog_mock): """ Test a valid request from an authenticated user with enterprise tags. @@ -521,7 +521,8 @@ class SubmitFeedbackTest(EnterpriseServiceMockMixin, TestCase): self._assert_datadog_called(datadog_mock, datadog_tags) @httpretty.activate - @override_settings(ZENDESK_CUSTOM_FIELDS=TEST_ZENDESK_CUSTOM_FIELD_CONFIG, ENABLE_ENTERPRISE_INTEGRATION=True) + @override_settings(ZENDESK_CUSTOM_FIELDS=TEST_ZENDESK_CUSTOM_FIELD_CONFIG) + @mock.patch.dict("django.conf.settings.FEATURES", dict(ENABLE_ENTERPRISE_INTEGRATION=True)) def test_request_with_anonymous_user_without_enterprise_info(self, zendesk_mock_class, datadog_mock): """ Test tags related to enterprise should not be there in case an unauthenticated user. @@ -545,7 +546,8 @@ class SubmitFeedbackTest(EnterpriseServiceMockMixin, TestCase): self.assertNotEqual(datadog_mock.mock_calls, not_expected_datadog_calls) @httpretty.activate - @override_settings(ZENDESK_CUSTOM_FIELDS=TEST_ZENDESK_CUSTOM_FIELD_CONFIG, ENABLE_ENTERPRISE_INTEGRATION=True) + @override_settings(ZENDESK_CUSTOM_FIELDS=TEST_ZENDESK_CUSTOM_FIELD_CONFIG) + @mock.patch.dict("django.conf.settings.FEATURES", dict(ENABLE_ENTERPRISE_INTEGRATION=True)) def test_tags_in_request_with_auth_user_with_enterprise_info(self, zendesk_mock_class, datadog_mock): """ Test tags related to enterprise should be there in case the request is generated by an authenticated user. diff --git a/lms/djangoapps/ccx/tests/test_field_override_performance.py b/lms/djangoapps/ccx/tests/test_field_override_performance.py index eb5dbde16a5bf7c5541a23552e47992b25b29438..f560b664abcedf2f32de374f4cf56b675b5a80d4 100644 --- a/lms/djangoapps/ccx/tests/test_field_override_performance.py +++ b/lms/djangoapps/ccx/tests/test_field_override_performance.py @@ -194,7 +194,6 @@ class FieldOverridePerformanceTestCase(FieldOverrideTestMixin, ProceduralCourseT @override_settings( XBLOCK_FIELD_DATA_WRAPPERS=[], MODULESTORE_FIELD_OVERRIDE_PROVIDERS=[], - ENABLE_ENTERPRISE_INTEGRATION=False, ) def test_field_overrides(self, overrides, course_width, enable_ccx, view_as_ccx): """ diff --git a/lms/djangoapps/courseware/tests/test_course_info.py b/lms/djangoapps/courseware/tests/test_course_info.py index 45b91bfe972c1002c824bfe79f81db5549d744fb..45edfe6419423fbf6d225e355ea03660c6131439 100644 --- a/lms/djangoapps/courseware/tests/test_course_info.py +++ b/lms/djangoapps/courseware/tests/test_course_info.py @@ -348,7 +348,7 @@ class CourseInfoTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase): @attr(shard=1) -@override_settings(FEATURES=dict(settings.FEATURES, EMBARGO=False), ENABLE_ENTERPRISE_INTEGRATION=False) +@override_settings(FEATURES=dict(settings.FEATURES, EMBARGO=False)) class SelfPacedCourseInfoTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase): """ Tests for the info page of self-paced courses. diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index b65169d5e531c0b30030fd47efc6ee953a6fe12d..aa9b4c316ba31b5f978501ee3f0e0b6fc988ec62 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -1202,7 +1202,6 @@ class StartDateTests(ModuleStoreTestCase): # pylint: disable=protected-access, no-member @attr(shard=1) -@override_settings(ENABLE_ENTERPRISE_INTEGRATION=False) class ProgressPageBaseTests(ModuleStoreTestCase): """ Base class for progress page tests. diff --git a/lms/djangoapps/discussion/tests/test_views.py b/lms/djangoapps/discussion/tests/test_views.py index f3be48497713a532682890a5b9368c239cc02236..65faab5325a9fac78498cf6046eaa7ae68e1ee01 100644 --- a/lms/djangoapps/discussion/tests/test_views.py +++ b/lms/djangoapps/discussion/tests/test_views.py @@ -448,7 +448,7 @@ class SingleThreadQueryCountTestCase(ForumsEnableMixin, ModuleStoreTestCase): """ Call single_thread and assert that it returns what we expect. """ - with override_settings(ENABLE_ENTERPRISE_INTEGRATION=enterprise_enabled): + with patch.dict("django.conf.settings.FEATURES", dict(ENABLE_ENTERPRISE_INTEGRATION=enterprise_enabled)): response = views.single_thread( request, course.id.to_deprecated_string(), diff --git a/lms/envs/common.py b/lms/envs/common.py index 096fbd81d1388216eb9fd9cf095f4995485b3820..a6b1b6a47d6cd5aa5f50693653c66c53beeb82d9 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -406,6 +406,9 @@ FEATURES = { # Whether course goals is enabled. 'ENABLE_COURSE_GOALS': True, + + # Set to enable Enterprise integration + 'ENABLE_ENTERPRISE_INTEGRATION': False, } # Settings for the course reviews tool template and identification key, set either to None to disable course reviews @@ -3265,6 +3268,8 @@ HELP_TOKENS_BOOKS = { # However, for all intents and purposes this service is treated as a standalone IDA. # These configuration settings are specific to the Enterprise service and you should # not find references to them within the edx-platform project. +# +# Only used if FEATURES['ENABLE_ENTERPRISE_INTEGRATION'] == True. ENTERPRISE_ENROLLMENT_API_URL = LMS_ROOT_URL + LMS_ENROLLMENT_API_PATH ENTERPRISE_PUBLIC_ENROLLMENT_API_URL = ENTERPRISE_ENROLLMENT_API_URL diff --git a/lms/envs/devstack_docker.py b/lms/envs/devstack_docker.py index fd0a686f9980f74aa3fce991c06d40dec2e2d640..a3c04d51eaf8792c4a1374fdd7653749e4f20949 100644 --- a/lms/envs/devstack_docker.py +++ b/lms/envs/devstack_docker.py @@ -20,7 +20,6 @@ ECOMMERCE_API_URL = 'http://edx.devstack.ecommerce:18130/api/v2' COMMENTS_SERVICE_URL = 'http://edx.devstack.forum:4567' ENTERPRISE_API_URL = '{}/enterprise/api/v1/'.format(LMS_ROOT_URL) -ENABLE_ENTERPRISE_INTEGRATION = False CREDENTIALS_INTERNAL_SERVICE_URL = 'http://edx.devstack.credentials:18150' CREDENTIALS_PUBLIC_SERVICE_URL = 'http://localhost:18150' @@ -39,7 +38,8 @@ FEATURES.update({ 'ENABLE_COURSE_DISCOVERY': False, 'ENABLE_DASHBOARD_SEARCH': False, 'ENABLE_DISCUSSION_SERVICE': True, - 'SHOW_HEADER_LANGUAGE_SELECTOR': True + 'SHOW_HEADER_LANGUAGE_SELECTOR': True, + 'ENABLE_ENTERPRISE_INTEGRATION': False, }) ENABLE_MKTG_SITE = os.environ.get('ENABLE_MARKETING_SITE', False) diff --git a/lms/envs/test.py b/lms/envs/test.py index b712c5d983562460a3fed1c487c9e059552f10ce..9841b39976986c387bfdc040a38cd5d56b54348c 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -601,7 +601,6 @@ COMPREHENSIVE_THEME_LOCALE_PATHS = [REPO_ROOT / "themes/conf/locale", ] LMS_ROOT_URL = "http://localhost:8000" -ENABLE_ENTERPRISE_INTEGRATION = False ECOMMERCE_API_URL = 'https://ecommerce.example.com/api/v2/' ENTERPRISE_API_URL = 'http://enterprise.example.com/enterprise/api/v1/' ENTERPRISE_CONSENT_API_URL = 'http://enterprise.example.com/consent/api/v1/' diff --git a/openedx/features/enterprise_support/api.py b/openedx/features/enterprise_support/api.py index 655afd5a46affe29b7b192f57913995059a83992..488921561f269882489b1edb9d43a2508860cc73 100644 --- a/openedx/features/enterprise_support/api.py +++ b/openedx/features/enterprise_support/api.py @@ -322,7 +322,7 @@ def enterprise_enabled(): """ Determines whether the Enterprise app is installed """ - return 'enterprise' in settings.INSTALLED_APPS and getattr(settings, 'ENABLE_ENTERPRISE_INTEGRATION', True) + return 'enterprise' in settings.INSTALLED_APPS and settings.FEATURES.get('ENABLE_ENTERPRISE_INTEGRATION', False) def enterprise_customer_uuid_for_request(request): diff --git a/openedx/features/enterprise_support/tests/test_api.py b/openedx/features/enterprise_support/tests/test_api.py index 0cd9eec22e1771d916ac6a4e249b19dc248e5551..e791fb63f56e10e7a1099d92299447e419bb414f 100644 --- a/openedx/features/enterprise_support/tests/test_api.py +++ b/openedx/features/enterprise_support/tests/test_api.py @@ -31,6 +31,10 @@ from openedx.features.enterprise_support.utils import get_cache_key from student.tests.factories import UserFactory +FEATURES_WITH_ENTERPRISE_ENABLED = settings.FEATURES.copy() +FEATURES_WITH_ENTERPRISE_ENABLED['ENABLE_ENTERPRISE_INTEGRATION'] = True + + class MockEnrollment(mock.MagicMock): """ Mock object for an enrollment which has a consistent string representation @@ -41,7 +45,7 @@ class MockEnrollment(mock.MagicMock): @ddt.ddt -@override_settings(ENABLE_ENTERPRISE_INTEGRATION=True) +@override_settings(FEATURES=FEATURES_WITH_ENTERPRISE_ENABLED) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase): """