From 82f8196f87d6cc2288a1fba5b7b3f26900792fa2 Mon Sep 17 00:00:00 2001 From: Troy Sankey Date: Thu, 27 Feb 2020 16:19:28 -0500 Subject: [PATCH] Revert "Rename values in SiteConfiguration/History (1/3) (retry)" --- .../discussion/tests/test_signals.py | 8 +--- .../tests/views/test_instructor_dashboard.py | 14 +------ .../ace_common/tests/test_tracking.py | 3 -- openedx/core/djangoapps/catalog/views.py | 1 - .../commands/tests/test_notify_credentials.py | 1 - .../credentials/tests/test_signals.py | 1 - .../djangoapps/programs/tests/test_signals.py | 1 - .../commands/tests/send_email_base.py | 10 +---- .../schedules/tests/test_resolvers.py | 1 - .../create_or_update_site_configuration.py | 4 -- .../migrations/0004_add_site_values_field.py | 28 ------------- .../djangoapps/site_configuration/models.py | 23 +--------- .../site_configuration/tests/mixins.py | 42 ++++++++----------- .../tests/test_middleware.py | 6 --- .../site_configuration/tests/test_models.py | 22 ---------- .../site_configuration/tests/test_util.py | 6 +-- .../create_sites_and_configurations.py | 7 +--- .../tests/test_sync_hubspot_contacts.py | 1 - .../content_type_gating/tests/test_models.py | 30 +++---------- .../tests/test_models.py | 22 ++-------- .../tests/test_discount_restriction_models.py | 7 +--- 21 files changed, 39 insertions(+), 199 deletions(-) delete mode 100644 openedx/core/djangoapps/site_configuration/migrations/0004_add_site_values_field.py diff --git a/lms/djangoapps/discussion/tests/test_signals.py b/lms/djangoapps/discussion/tests/test_signals.py index e303bc11c9be..f30a422e0a15 100644 --- a/lms/djangoapps/discussion/tests/test_signals.py +++ b/lms/djangoapps/discussion/tests/test_signals.py @@ -28,9 +28,7 @@ def setUp(self): @mock.patch('lms.djangoapps.discussion.signals.handlers.send_message') def test_comment_created_signal_sends_message(self, mock_send_message, mock_get_current_site): site_config = SiteConfigurationFactory.create(site=self.site) - enable_notifications_cfg = {ENABLE_FORUM_NOTIFICATIONS_FOR_SITE_KEY: True} - site_config.site_values = enable_notifications_cfg - site_config.values = enable_notifications_cfg + site_config.values[ENABLE_FORUM_NOTIFICATIONS_FOR_SITE_KEY] = True site_config.save() mock_get_current_site.return_value = self.site signals.comment_created.send(sender=self.sender, user=self.user, post=self.post) @@ -58,9 +56,7 @@ def test_comment_created_signal_msg_not_sent_with_site_config_disabled( self, mock_send_message, mock_get_current_site ): site_config = SiteConfigurationFactory.create(site=self.site) - enable_notifications_cfg = {ENABLE_FORUM_NOTIFICATIONS_FOR_SITE_KEY: False} - site_config.site_values = enable_notifications_cfg - site_config.values = enable_notifications_cfg + site_config.values[ENABLE_FORUM_NOTIFICATIONS_FOR_SITE_KEY] = False site_config.save() mock_get_current_site.return_value = self.site signals.comment_created.send(sender=self.sender, user=self.user, post=self.post) diff --git a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py index 58d29ae5c1b9..ecf76df5ee3b 100644 --- a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py +++ b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py @@ -166,12 +166,7 @@ def test_membership_reason_field_visibility(self, enbale_reason_field): "ENABLE_MANUAL_ENROLLMENT_REASON_FIELD": enbale_reason_field } site = Site.objects.first() - SiteConfiguration.objects.create( - site=site, - site_values=configuration_values, - values=configuration_values, - enabled=True - ) + SiteConfiguration.objects.create(site=site, values=configuration_values, enabled=True) url = reverse( 'instructor_dashboard', @@ -199,12 +194,7 @@ def test_membership_site_configuration_role(self): ] } site = Site.objects.first() - SiteConfiguration.objects.create( - site=site, - site_values=configuration_values, - values=configuration_values, - enabled=True - ) + SiteConfiguration.objects.create(site=site, values=configuration_values, enabled=True) url = reverse( 'instructor_dashboard', kwargs={ diff --git a/openedx/core/djangoapps/ace_common/tests/test_tracking.py b/openedx/core/djangoapps/ace_common/tests/test_tracking.py index 1412acf25283..85f71eaf94c8 100644 --- a/openedx/core/djangoapps/ace_common/tests/test_tracking.py +++ b/openedx/core/djangoapps/ace_common/tests/test_tracking.py @@ -122,9 +122,6 @@ def test_missing_settings(self): @override_settings(GOOGLE_ANALYTICS_TRACKING_ID='UA-123456-1') def test_site_config_override(self): site_config = SiteConfigurationFactory.create( - site_values=dict( - GOOGLE_ANALYTICS_ACCOUNT='UA-654321-1' - ), values=dict( GOOGLE_ANALYTICS_ACCOUNT='UA-654321-1' ) diff --git a/openedx/core/djangoapps/catalog/views.py b/openedx/core/djangoapps/catalog/views.py index 41874667c1ee..ecc1fd381fb3 100644 --- a/openedx/core/djangoapps/catalog/views.py +++ b/openedx/core/djangoapps/catalog/views.py @@ -27,7 +27,6 @@ def cache_programs(request): SiteConfiguration.objects.create( site=request.site, enabled=True, - site_values={"COURSE_CATALOG_API_URL": "{catalog_url}/api/v1/".format(catalog_url=CATALOG_STUB_URL)}, values={"COURSE_CATALOG_API_URL": "{catalog_url}/api/v1/".format(catalog_url=CATALOG_STUB_URL)} ) diff --git a/openedx/core/djangoapps/credentials/management/commands/tests/test_notify_credentials.py b/openedx/core/djangoapps/credentials/management/commands/tests/test_notify_credentials.py index d84ad0669bac..fb94f17f5bb7 100644 --- a/openedx/core/djangoapps/credentials/management/commands/tests/test_notify_credentials.py +++ b/openedx/core/djangoapps/credentials/management/commands/tests/test_notify_credentials.py @@ -157,7 +157,6 @@ def test_page_size(self): @mock.patch(COMMAND_MODULE + '.handle_cert_change') def test_site(self, mock_grade_interesting, mock_cert_change): site_config = SiteConfigurationFactory.create( - site_values={'course_org_filter': ['testX']}, values={'course_org_filter': ['testX']}, ) diff --git a/openedx/core/djangoapps/credentials/tests/test_signals.py b/openedx/core/djangoapps/credentials/tests/test_signals.py index ef2a8196d525..0ad7d47bc459 100644 --- a/openedx/core/djangoapps/credentials/tests/test_signals.py +++ b/openedx/core/djangoapps/credentials/tests/test_signals.py @@ -110,7 +110,6 @@ def test_send_grade_without_issuance_enabled(self, _mock_is_course_run_in_a_prog def test_send_grade_records_enabled(self, _mock_is_course_run_in_a_program, mock_send_grade_to_credentials, _mock_is_learner_issuance_enabled): site_config = SiteConfigurationFactory.create( - site_values={'course_org_filter': [self.key.org]}, values={'course_org_filter': [self.key.org]}, ) diff --git a/openedx/core/djangoapps/programs/tests/test_signals.py b/openedx/core/djangoapps/programs/tests/test_signals.py index 82c5299cb7b5..1a524bb395ad 100644 --- a/openedx/core/djangoapps/programs/tests/test_signals.py +++ b/openedx/core/djangoapps/programs/tests/test_signals.py @@ -146,7 +146,6 @@ def test_records_enabled(self, mock_is_learner_issuance_enabled, mock_task): mock_is_learner_issuance_enabled.return_value = True site_config = SiteConfigurationFactory.create( - site_values={'course_org_filter': ['edX']}, values={'course_org_filter': ['edX']}, ) diff --git a/openedx/core/djangoapps/schedules/management/commands/tests/send_email_base.py b/openedx/core/djangoapps/schedules/management/commands/tests/send_email_base.py index 9da5d0e81108..95ae1bf8a513 100644 --- a/openedx/core/djangoapps/schedules/management/commands/tests/send_email_base.py +++ b/openedx/core/djangoapps/schedules/management/commands/tests/send_email_base.py @@ -307,14 +307,8 @@ def test_enqueue_config(self, is_enabled): def test_site_config(self, this_org_list, other_org_list, expected_message_count, mock_ace): filtered_org = 'filtered_org' unfiltered_org = 'unfiltered_org' - this_config = SiteConfigurationFactory.create( - site_values={'course_org_filter': this_org_list}, - values={'course_org_filter': this_org_list} - ) - other_config = SiteConfigurationFactory.create( - site_values={'course_org_filter': other_org_list}, - values={'course_org_filter': other_org_list} - ) + this_config = SiteConfigurationFactory.create(values={'course_org_filter': this_org_list}) + other_config = SiteConfigurationFactory.create(values={'course_org_filter': other_org_list}) for config in (this_config, other_config): ScheduleConfigFactory.create(site=config.site) diff --git a/openedx/core/djangoapps/schedules/tests/test_resolvers.py b/openedx/core/djangoapps/schedules/tests/test_resolvers.py index 4c792b860fbd..12305a24ccb3 100644 --- a/openedx/core/djangoapps/schedules/tests/test_resolvers.py +++ b/openedx/core/djangoapps/schedules/tests/test_resolvers.py @@ -88,7 +88,6 @@ def test_get_course_org_filter_include__in(self, course_org_filter, expected_org ) def test_get_course_org_filter_exclude__in(self, course_org_filter, expected_org_list): SiteConfigurationFactory.create( - site_values={'course_org_filter': course_org_filter}, values={'course_org_filter': course_org_filter}, ) mock_query = Mock() diff --git a/openedx/core/djangoapps/site_configuration/management/commands/create_or_update_site_configuration.py b/openedx/core/djangoapps/site_configuration/management/commands/create_or_update_site_configuration.py index 2c670b513fbd..7c57b10e2a5c 100644 --- a/openedx/core/djangoapps/site_configuration/management/commands/create_or_update_site_configuration.py +++ b/openedx/core/djangoapps/site_configuration/management/commands/create_or_update_site_configuration.py @@ -107,10 +107,6 @@ def handle(self, *args, **options): site_configuration.values.update(site_configuration_values) else: site_configuration.values = site_configuration_values - if site_configuration.site_values: - site_configuration.site_values.update(site_configuration_values) - else: - site_configuration.site_values = site_configuration_values if enabled is not None: site_configuration.enabled = enabled diff --git a/openedx/core/djangoapps/site_configuration/migrations/0004_add_site_values_field.py b/openedx/core/djangoapps/site_configuration/migrations/0004_add_site_values_field.py deleted file mode 100644 index fc13fff806de..000000000000 --- a/openedx/core/djangoapps/site_configuration/migrations/0004_add_site_values_field.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.28 on 2020-02-19 16:50 -from __future__ import unicode_literals - -import collections -from django.db import migrations -import jsonfield.encoder -import jsonfield.fields - - -class Migration(migrations.Migration): - - dependencies = [ - ('site_configuration', '0003_auto_20200217_1058'), - ] - - operations = [ - migrations.AddField( - model_name='siteconfiguration', - name='site_values', - field=jsonfield.fields.JSONField(blank=True, default=dict, dump_kwargs={'cls': jsonfield.encoder.JSONEncoder, 'separators': (',', ':')}, load_kwargs={'object_pairs_hook': collections.OrderedDict}), - ), - migrations.AddField( - model_name='siteconfigurationhistory', - name='site_values', - field=jsonfield.fields.JSONField(blank=True, dump_kwargs={'cls': jsonfield.encoder.JSONEncoder, 'separators': (',', ':')}, load_kwargs={'object_pairs_hook': collections.OrderedDict}), - ), - ] diff --git a/openedx/core/djangoapps/site_configuration/models.py b/openedx/core/djangoapps/site_configuration/models.py index 683fae6af5ef..fb5d885447f8 100644 --- a/openedx/core/djangoapps/site_configuration/models.py +++ b/openedx/core/djangoapps/site_configuration/models.py @@ -25,23 +25,12 @@ class SiteConfiguration(models.Model): Fields: site (OneToOneField): one to one field relating each configuration to a single site - site_values (JSONField): json field to store configurations for a site + values (JSONField): json field to store configurations for a site .. no_pii: """ site = models.OneToOneField(Site, related_name='configuration', on_delete=models.CASCADE) enabled = models.BooleanField(default=False, verbose_name=u"Enabled") - site_values = JSONField( - null=False, - blank=True, - # The actual default value is determined by calling the given callable. - # Therefore, the default here is just {}, since that is the result of - # calling `dict`. - default=dict, - load_kwargs={'object_pairs_hook': collections.OrderedDict} - ) - # TODO: Delete this deprecated field during the later stages of the rollout - # which renames 'values' to 'site_values'. values = JSONField( null=False, blank=True, @@ -157,19 +146,12 @@ class SiteConfigurationHistory(TimeStampedModel): Fields: site (ForeignKey): foreign-key to django Site - site_values (JSONField): json field to store configurations for a site + values (JSONField): json field to store configurations for a site .. no_pii: """ site = models.ForeignKey(Site, related_name='configuration_histories', on_delete=models.CASCADE) enabled = models.BooleanField(default=False, verbose_name=u"Enabled") - site_values = JSONField( - null=False, - blank=True, - load_kwargs={'object_pairs_hook': collections.OrderedDict} - ) - # TODO: Delete this deprecated field during the later stages of the rollout - # which renames 'values' to 'site_values'. values = JSONField( null=False, blank=True, @@ -203,7 +185,6 @@ def update_site_configuration_history(sender, instance, **kwargs): # pylint: di """ SiteConfigurationHistory.objects.create( site=instance.site, - site_values=instance.values, values=instance.values, enabled=instance.enabled, ) diff --git a/openedx/core/djangoapps/site_configuration/tests/mixins.py b/openedx/core/djangoapps/site_configuration/tests/mixins.py index 95294d289192..6c30b747b938 100644 --- a/openedx/core/djangoapps/site_configuration/tests/mixins.py +++ b/openedx/core/djangoapps/site_configuration/tests/mixins.py @@ -14,39 +14,33 @@ def setUp(self): super(SiteMixin, self).setUp() self.site = SiteFactory.create() - site_config = { - "SITE_NAME": self.site.domain, - "course_email_from_addr": "fake@example.com", - "course_email_template_name": "fake_email_template", - "course_org_filter": "fakeX" - } self.site_configuration = SiteConfigurationFactory.create( site=self.site, - site_values=site_config, - # TODO: Remove this deprecated value eventually. - values=site_config + values={ + "SITE_NAME": self.site.domain, + "course_email_from_addr": "fake@example.com", + "course_email_template_name": "fake_email_template", + "course_org_filter": "fakeX" + } ) self.site_other = SiteFactory.create( domain='testserver.fakeother', name='testserver.fakeother' ) - site_config_other = { - "SITE_NAME": self.site_other.domain, - "SESSION_COOKIE_DOMAIN": self.site_other.domain, - "course_org_filter": "fakeOtherX", - "ENABLE_MKTG_SITE": True, - "SHOW_ECOMMERCE_REPORTS": True, - "MKTG_URLS": { - "ROOT": "https://marketing.fakeother", - "ABOUT": "/fake-about" - } - } self.site_configuration_other = SiteConfigurationFactory.create( site=self.site_other, - site_values=site_config_other, - # TODO: Remove this deprecated value eventually. - values=site_config_other + values={ + "SITE_NAME": self.site_other.domain, + "SESSION_COOKIE_DOMAIN": self.site_other.domain, + "course_org_filter": "fakeOtherX", + "ENABLE_MKTG_SITE": True, + "SHOW_ECOMMERCE_REPORTS": True, + "MKTG_URLS": { + "ROOT": "https://marketing.fakeother", + "ABOUT": "/fake-about" + } + } ) # Initialize client with default site domain @@ -62,8 +56,6 @@ def set_up_site(self, domain, site_configuration_values): ) __ = SiteConfigurationFactory.create( site=site, - site_values=site_configuration_values, - # TODO: Remove this deprecated value eventually. values=site_configuration_values ) self.use_site(site) diff --git a/openedx/core/djangoapps/site_configuration/tests/test_middleware.py b/openedx/core/djangoapps/site_configuration/tests/test_middleware.py index c1dcc8dd37e7..1932b7e104ca 100644 --- a/openedx/core/djangoapps/site_configuration/tests/test_middleware.py +++ b/openedx/core/djangoapps/site_configuration/tests/test_middleware.py @@ -38,9 +38,6 @@ def setUp(self): ) self.site_configuration = SiteConfigurationFactory.create( site=self.site, - site_values={ - "SESSION_COOKIE_DOMAIN": self.site.domain, - }, values={ "SESSION_COOKIE_DOMAIN": self.site.domain, } @@ -76,9 +73,6 @@ def setUp(self): ) self.site_configuration = SiteConfigurationFactory.create( site=self.site, - site_values={ - "SESSION_COOKIE_DOMAIN": self.site.domain, - }, values={ "SESSION_COOKIE_DOMAIN": self.site.domain, } diff --git a/openedx/core/djangoapps/site_configuration/tests/test_models.py b/openedx/core/djangoapps/site_configuration/tests/test_models.py index 4b69d57f5870..0200c5881235 100644 --- a/openedx/core/djangoapps/site_configuration/tests/test_models.py +++ b/openedx/core/djangoapps/site_configuration/tests/test_models.py @@ -82,8 +82,6 @@ def test_site_configuration_post_update_receiver(self): site=self.site, ) - site_configuration.site_values = {'test': 'test'} - # TODO: Remove this deprecated value eventually. site_configuration.values = {'test': 'test'} site_configuration.save() @@ -133,8 +131,6 @@ def test_get_value(self): # add SiteConfiguration to database site_configuration = SiteConfigurationFactory.create( site=self.site, - site_values=self.test_config1, - # TODO: Remove this deprecated value eventually. values=self.test_config1, ) @@ -183,8 +179,6 @@ def test_invalid_data_error_on_get_value(self): # add SiteConfiguration to database site_configuration = SiteConfigurationFactory.create( site=self.site, - site_values=invalid_data, - # TODO: Remove this deprecated value eventually. values=invalid_data, ) @@ -206,14 +200,10 @@ def test_get_value_for_org(self): # add SiteConfiguration to database SiteConfigurationFactory.create( site=self.site, - site_values=self.test_config1, - # TODO: Remove this deprecated value eventually. values=self.test_config1, ) SiteConfigurationFactory.create( site=self.site2, - site_values=self.test_config2, - # TODO: Remove this deprecated value eventually. values=self.test_config2, ) @@ -295,14 +285,10 @@ def test_get_site_for_org(self): # add SiteConfiguration to database config1 = SiteConfigurationFactory.create( site=self.site, - site_values=self.test_config1, - # TODO: Remove this deprecated value eventually. values=self.test_config1, ) config2 = SiteConfigurationFactory.create( site=self.site2, - site_values=self.test_config2, - # TODO: Remove this deprecated value eventually. values=self.test_config2, ) @@ -328,14 +314,10 @@ def test_get_all_orgs(self): # add SiteConfiguration to database SiteConfigurationFactory.create( site=self.site, - site_values=self.test_config1, - # TODO: Remove this deprecated value eventually. values=self.test_config1, ) SiteConfigurationFactory.create( site=self.site2, - site_values=self.test_config2, - # TODO: Remove this deprecated value eventually. values=self.test_config2, ) @@ -350,15 +332,11 @@ def test_get_all_orgs_returns_only_enabled(self): # add SiteConfiguration to database SiteConfigurationFactory.create( site=self.site, - site_values=self.test_config1, - # TODO: Remove this deprecated value eventually. values=self.test_config1, enabled=False, ) SiteConfigurationFactory.create( site=self.site2, - site_values=self.test_config2, - # TODO: Remove this deprecated value eventually. values=self.test_config2, ) diff --git a/openedx/core/djangoapps/site_configuration/tests/test_util.py b/openedx/core/djangoapps/site_configuration/tests/test_util.py index 6c13a5fadc14..bd6277dcc80b 100644 --- a/openedx/core/djangoapps/site_configuration/tests/test_util.py +++ b/openedx/core/djangoapps/site_configuration/tests/test_util.py @@ -29,10 +29,9 @@ def _decorated(*args, **kwargs): # pylint: disable=missing-docstring site, __ = Site.objects.get_or_create(domain=domain, name=domain) site_configuration, created = SiteConfiguration.objects.get_or_create( site=site, - defaults={"enabled": True, "site_values": configuration, "values": configuration}, + defaults={"enabled": True, "values": configuration}, ) if not created: - site_configuration.site_values = configuration site_configuration.values = configuration site_configuration.save() @@ -57,10 +56,9 @@ def with_site_configuration_context(domain="test.localhost", configuration=None) site, __ = Site.objects.get_or_create(domain=domain, name=domain) site_configuration, created = SiteConfiguration.objects.get_or_create( site=site, - defaults={"enabled": True, "site_values": configuration, "values": configuration}, + defaults={"enabled": True, "values": configuration}, ) if not created: - site_configuration.site_values = configuration site_configuration.values = configuration site_configuration.save() diff --git a/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py b/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py index 41e3ad59de46..bcea2a4c0d7b 100644 --- a/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py +++ b/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py @@ -113,12 +113,7 @@ def _create_sites(self, site_domain, theme_dir_name, site_configuration): SiteTheme.objects.create(site=site, theme_dir_name=theme_dir_name) LOG.info(u"Creating '{site_name}' SiteConfiguration".format(site_name=site_domain)) - SiteConfiguration.objects.create( - site=site, - site_values=site_configuration, - values=site_configuration, - enabled=True - ) + SiteConfiguration.objects.create(site=site, values=site_configuration, enabled=True) else: LOG.info(u"'{site_domain}' site already exists".format(site_domain=site_domain)) diff --git a/openedx/core/djangoapps/user_api/management/tests/test_sync_hubspot_contacts.py b/openedx/core/djangoapps/user_api/management/tests/test_sync_hubspot_contacts.py index d61bd05f484a..912a5e4fcf0e 100644 --- a/openedx/core/djangoapps/user_api/management/tests/test_sync_hubspot_contacts.py +++ b/openedx/core/djangoapps/user_api/management/tests/test_sync_hubspot_contacts.py @@ -31,7 +31,6 @@ def setUpClass(cls): super(TestHubspotSyncCommand, cls).setUpClass() cls.site_config = SiteConfigurationFactory() cls.hubspot_site_config = SiteConfigurationFactory.create( - site_values={'HUBSPOT_API_KEY': 'test_key'}, values={'HUBSPOT_API_KEY': 'test_key'}, ) cls.users = [] diff --git a/openedx/features/content_type_gating/tests/test_models.py b/openedx/features/content_type_gating/tests/test_models.py index c6cf276bdcfb..a13c6bf75658 100644 --- a/openedx/features/content_type_gating/tests/test_models.py +++ b/openedx/features/content_type_gating/tests/test_models.py @@ -131,14 +131,8 @@ def test_config_overrides(self, global_setting, site_setting, org_setting, cours # there are no leaks of configuration across contexts non_test_course_enabled = CourseOverviewFactory.create(org='non-test-org-enabled') non_test_course_disabled = CourseOverviewFactory.create(org='non-test-org-disabled') - non_test_site_cfg_enabled = SiteConfigurationFactory.create( - site_values={'course_org_filter': non_test_course_enabled.org}, - values={'course_org_filter': non_test_course_enabled.org} - ) - non_test_site_cfg_disabled = SiteConfigurationFactory.create( - site_values={'course_org_filter': non_test_course_disabled.org}, - values={'course_org_filter': non_test_course_disabled.org} - ) + non_test_site_cfg_enabled = SiteConfigurationFactory.create(values={'course_org_filter': non_test_course_enabled.org}) + non_test_site_cfg_disabled = SiteConfigurationFactory.create(values={'course_org_filter': non_test_course_disabled.org}) ContentTypeGatingConfig.objects.create(course=non_test_course_enabled, enabled=True, enabled_as_of=datetime(2018, 1, 1)) ContentTypeGatingConfig.objects.create(course=non_test_course_disabled, enabled=False) @@ -149,10 +143,7 @@ def test_config_overrides(self, global_setting, site_setting, org_setting, cours # Set up test objects test_course = CourseOverviewFactory.create(org='test-org') - test_site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': test_course.org}, - values={'course_org_filter': test_course.org} - ) + test_site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': test_course.org}) ContentTypeGatingConfig.objects.create(enabled=global_setting, enabled_as_of=datetime(2018, 1, 1)) ContentTypeGatingConfig.objects.create(course=test_course, enabled=course_setting, enabled_as_of=datetime(2018, 1, 1)) @@ -175,10 +166,7 @@ def test_all_current_course_configs(self): for global_setting in (True, False, None): ContentTypeGatingConfig.objects.create(enabled=global_setting, enabled_as_of=datetime(2018, 1, 1)) for site_setting in (True, False, None): - test_site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': []}, - values={'course_org_filter': []} - ) + test_site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': []}) ContentTypeGatingConfig.objects.create(site=test_site_cfg.site, enabled=site_setting, enabled_as_of=datetime(2018, 1, 1)) for org_setting in (True, False, None): @@ -291,10 +279,7 @@ def test_caching_site(self): def test_caching_org(self): course = CourseOverviewFactory.create(org='test-org') - site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': course.org}, - values={'course_org_filter': course.org} - ) + site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': course.org}) org_config = ContentTypeGatingConfig(org=course.org, enabled=True, enabled_as_of=datetime(2018, 1, 1)) org_config.save() @@ -339,10 +324,7 @@ def test_caching_org(self): def test_caching_course(self): course = CourseOverviewFactory.create(org='test-org') - site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': course.org}, - values={'course_org_filter': course.org} - ) + site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': course.org}) course_config = ContentTypeGatingConfig(course=course, enabled=True, enabled_as_of=datetime(2018, 1, 1)) course_config.save() diff --git a/openedx/features/course_duration_limits/tests/test_models.py b/openedx/features/course_duration_limits/tests/test_models.py index fe4865fd774c..58078777f1a9 100644 --- a/openedx/features/course_duration_limits/tests/test_models.py +++ b/openedx/features/course_duration_limits/tests/test_models.py @@ -142,11 +142,9 @@ def test_config_overrides(self, global_setting, site_setting, org_setting, cours non_test_course_enabled = CourseOverviewFactory.create(org='non-test-org-enabled') non_test_course_disabled = CourseOverviewFactory.create(org='non-test-org-disabled') non_test_site_cfg_enabled = SiteConfigurationFactory.create( - site_values={'course_org_filter': non_test_course_enabled.org}, values={'course_org_filter': non_test_course_enabled.org} ) non_test_site_cfg_disabled = SiteConfigurationFactory.create( - site_values={'course_org_filter': non_test_course_disabled.org}, values={'course_org_filter': non_test_course_disabled.org} ) @@ -159,10 +157,7 @@ def test_config_overrides(self, global_setting, site_setting, org_setting, cours # Set up test objects test_course = CourseOverviewFactory.create(org='test-org') - test_site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': test_course.org}, - values={'course_org_filter': test_course.org} - ) + test_site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': test_course.org}) if reverse_order: CourseDurationLimitConfig.objects.create(site=test_site_cfg.site, enabled=site_setting) @@ -190,10 +185,7 @@ def test_all_current_course_configs(self): for global_setting in (True, False, None): CourseDurationLimitConfig.objects.create(enabled=global_setting, enabled_as_of=datetime(2018, 1, 1)) for site_setting in (True, False, None): - test_site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': []}, - values={'course_org_filter': []} - ) + test_site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': []}) CourseDurationLimitConfig.objects.create( site=test_site_cfg.site, enabled=site_setting, enabled_as_of=datetime(2018, 1, 1) ) @@ -309,10 +301,7 @@ def test_caching_site(self): def test_caching_org(self): course = CourseOverviewFactory.create(org='test-org') - site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': course.org}, - values={'course_org_filter': course.org} - ) + site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': course.org}) org_config = CourseDurationLimitConfig(org=course.org, enabled=True, enabled_as_of=datetime(2018, 1, 1)) org_config.save() @@ -357,10 +346,7 @@ def test_caching_org(self): def test_caching_course(self): course = CourseOverviewFactory.create(org='test-org') - site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': course.org}, - values={'course_org_filter': course.org} - ) + site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': course.org}) course_config = CourseDurationLimitConfig(course=course, enabled=True, enabled_as_of=datetime(2018, 1, 1)) course_config.save() diff --git a/openedx/features/discounts/tests/test_discount_restriction_models.py b/openedx/features/discounts/tests/test_discount_restriction_models.py index 1de2ca7c7202..60343d052a36 100644 --- a/openedx/features/discounts/tests/test_discount_restriction_models.py +++ b/openedx/features/discounts/tests/test_discount_restriction_models.py @@ -59,11 +59,9 @@ def test_config_overrides(self, global_setting, site_setting, org_setting, cours non_test_course_disabled = CourseOverviewFactory.create(org='non-test-org-disabled') non_test_course_enabled = CourseOverviewFactory.create(org='non-test-org-enabled') non_test_site_cfg_disabled = SiteConfigurationFactory.create( - site_values={'course_org_filter': non_test_course_disabled.org}, values={'course_org_filter': non_test_course_disabled.org} ) non_test_site_cfg_enabled = SiteConfigurationFactory.create( - site_values={'course_org_filter': non_test_course_enabled.org}, values={'course_org_filter': non_test_course_enabled.org} ) @@ -76,10 +74,7 @@ def test_config_overrides(self, global_setting, site_setting, org_setting, cours # Set up test objects test_course = CourseOverviewFactory.create(org='test-org') - test_site_cfg = SiteConfigurationFactory.create( - site_values={'course_org_filter': test_course.org}, - values={'course_org_filter': test_course.org} - ) + test_site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': test_course.org}) DiscountRestrictionConfig.objects.create(disabled=global_setting) DiscountRestrictionConfig.objects.create(course=test_course, disabled=course_setting)