Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/djangoapps/student/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
EMAIL_SETTINGS_ELEMENT_ID = "#actions-item-email-settings-0"
ENABLED_SIGNALS = ['course_published']
MOCK_SETTINGS = {
'DISABLE_START_DATES': False,
'FEATURES': {
'DISABLE_START_DATES': False,
'ENABLE_MKTG_SITE': True,
'DISABLE_SET_JWT_COOKIES_FOR_TESTS': True,
},
Expand Down
11 changes: 3 additions & 8 deletions lms/djangoapps/branding/tests/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
)
from xmodule.modulestore.tests.factories import CourseFactory # pylint: disable=wrong-import-order

FEATURES_WITH_STARTDATE = settings.FEATURES.copy()
FEATURES_WITH_STARTDATE['DISABLE_START_DATES'] = False
FEATURES_WO_STARTDATE = settings.FEATURES.copy()
FEATURES_WO_STARTDATE['DISABLE_START_DATES'] = True


def mock_render_to_response(*args, **kwargs):
"""
Expand Down Expand Up @@ -67,7 +62,7 @@ def get_headers(cache_response):

return headers

@override_settings(FEATURES=FEATURES_WITH_STARTDATE)
@override_settings(DISABLE_START_DATES=False)
def test_none_user_index_access_with_startdate_fails(self):
"""
This is a regression test for a bug where the incoming user is
Expand All @@ -78,12 +73,12 @@ def test_none_user_index_access_with_startdate_fails(self):
response = self.client.get(reverse('root'))
assert response.status_code == 200

@override_settings(FEATURES=FEATURES_WITH_STARTDATE)
@override_settings(DISABLE_START_DATES=False)
def test_anon_user_with_startdate_index(self):
response = self.client.get('/')
assert response.status_code == 200

@override_settings(FEATURES=FEATURES_WO_STARTDATE)
@override_settings(DISABLE_START_DATES=True)
def test_anon_user_no_startdate_index(self):
response = self.client.get('/')
assert response.status_code == 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@


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 common.djangoapps.student.tests.factories import BetaTesterFactory
Expand Down Expand Up @@ -63,7 +63,7 @@ def setUp(self):
# 3 4 / 5
# \ /
# 6
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
@ddt.data(
(STUDENT, {}, {}, {}),
(STUDENT, {0: StartDateType.default}, {}, {}),
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/course_home_api/progress/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import dateutil
import ddt
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.timezone import now
from edx_toggles.toggles.testutils import override_waffle_flag
Expand Down Expand Up @@ -160,7 +161,7 @@ def get_subsection_show_grades(response):
assert response.status_code == 200
assert get_subsection_show_grades(response) is False

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_has_scheduled_content_data(self):
CourseEnrollment.enroll(self.user, self.course.id)
future = now() + timedelta(days=30)
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/access_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def check_start_date(user, days_early_for_beta, start, course_key, display_error
Returns:
AccessResponse: Either ACCESS_GRANTED or StartDateError.
"""
start_dates_disabled = settings.FEATURES["DISABLE_START_DATES"]
start_dates_disabled = settings.DISABLE_START_DATES
masquerading_as_student = is_masquerading_as_student(user, course_key)

if start_dates_disabled and not masquerading_as_student:
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/tests/test_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,14 @@ def setUp(self):
# common/test/data/2014/about/overview.html
self.xml_data = "about page 463139"

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_logged_in_xml(self):
self.setup_user()
url = reverse('about_course', args=[str(self.xml_course_id)])
resp = self.client.get(url)
self.assertContains(resp, self.xml_data)

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_anonymous_user_xml(self):
url = reverse('about_course', args=[str(self.xml_course_id)])
resp = self.client.get(url)
Expand Down
10 changes: 5 additions & 5 deletions lms/djangoapps/courseware/tests/test_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def test__has_access_to_block(self):
(False, TOMORROW, access_response.StartDateError)
)
@ddt.unpack
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test__has_access_to_block_staff_lock(self, visible_to_staff_only, start, expected_error_type=None):
"""
Tests that "visible_to_staff_only" overrides start date.
Expand Down Expand Up @@ -451,7 +451,7 @@ def test__has_access_to_block_beta_user(self):
(YESTERDAY, None)
) # ddt throws an error if I don't put the None argument there
@ddt.unpack
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test__has_access_to_block_with_start_date(self, start, expected_error_type):
"""
Tests that block access follows start date rules.
Expand Down Expand Up @@ -480,7 +480,7 @@ def test__has_access_to_block_with_start_date(self, start, expected_error_type):
(True, True, TOMORROW, False), # Masquerading, future start date - no access
)
@ddt.unpack
@patch.dict("django.conf.settings.FEATURES", {"DISABLE_START_DATES": False})
@override_settings(DISABLE_START_DATES=False)
def test_enforce_masquerade_start_dates_flag(self, flag_active, is_masquerading, start, expected_access=True):
"""
Test that the ENFORCE_MASQUERADE_START_DATES flag controls whether masquerading bypasses start date
Expand Down Expand Up @@ -864,7 +864,7 @@ def setUp(self):

@ddt.data(*(COURSE_TEST_DATA + LOAD_MOBILE_TEST_DATA + PREREQUISITES_TEST_DATA))
@ddt.unpack
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_course_overview_access(self, user_attr_name, action, course_attr_name):
"""
Check that a user's access to a course is equal to the user's access to
Expand Down Expand Up @@ -904,7 +904,7 @@ def test_course_overview_unsupported_action(self):
)
)
@ddt.unpack
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_course_catalog_access_num_queries(self, user_attr_name, action, course_attr_name):
ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime.datetime(2018, 1, 1))

Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/tests/test_masquerade.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def assertExpectedLanguageInPreference(self, user, expected_language_code):
'john', # Non-unicode username
'fôô@bar', # Unicode username with @, which is what the ENABLE_UNICODE_USERNAME feature allows
)
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_masquerade_as_specific_student(self, username):
"""
Test masquerading as a specific user.
Expand Down Expand Up @@ -409,7 +409,7 @@ def setUp(self):
self.course.user_partitions.append(self.user_partition)
modulestore().update_item(self.course, self.test_user.id)

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_get_masquerade_group(self):
"""
Tests that a staff member can masquerade as being in a group in a user partition
Expand Down
7 changes: 3 additions & 4 deletions lms/djangoapps/courseware/tests/test_self_paced_overrides.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tests for self-paced course due date overrides."""

import datetime
from unittest.mock import patch

import pytz
from django.test.utils import override_settings
Expand Down Expand Up @@ -88,7 +87,7 @@ def test_self_paced_due_date(self):
__, sp_section = self.setup_course(display_name="Self-Paced Course", self_paced=True)
assert sp_section.due is None

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_course_access_to_beta_users(self):
"""
Test that beta testers can access `self_paced` course prior to start date.
Expand Down Expand Up @@ -116,7 +115,7 @@ def test_course_access_to_beta_users(self):
assert has_access(beta_tester, 'load', self_paced_course)
assert has_access(beta_tester, 'load', self_paced_section, self_paced_course.id)

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_instructor_paced_discussion_xblock_visibility(self):
"""
Verify that discussion xblocks scheduled for release in the future are
Expand All @@ -129,7 +128,7 @@ def test_instructor_paced_discussion_xblock_visibility(self):
xblocks = get_accessible_discussion_xblocks(course, self.non_staff_user)
assert all((xblock.display_name == 'released') for xblock in xblocks)

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_self_paced_discussion_xblock_visibility(self):
"""
Regression test. Verify that discussion xblocks scheduled for release
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/tests/test_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ def setUp(self):
self.xml_data = "static 463139"
self.xml_url = "8e4cce2b4aaf4ba28b1220804619e41f"

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_logged_in_xml(self):
self.setup_user()
url = reverse('static_tab', args=[str(self.xml_course_key), self.xml_url])
resp = self.client.get(url)
self.assertContains(resp, self.xml_data)

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_anonymous_user_xml(self):
url = reverse('static_tab', args=[str(self.xml_course_key), self.xml_url])
resp = self.client.get(url)
Expand Down
18 changes: 9 additions & 9 deletions lms/djangoapps/courseware/tests/test_view_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@


import datetime
from unittest.mock import patch

import pytz
from django.test.utils import override_settings
from django.urls import reverse
from edx_toggles.toggles.testutils import override_waffle_flag

Expand Down Expand Up @@ -387,7 +387,7 @@ def test_staff_method_legacy(self):
# Test the _check_staff_legacy method which includes instructor dashboard checks
self._check_staff_legacy(self.course)

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_dark_launch_enrolled_student(self):
"""
Make sure that before course start, students can't access course
Expand All @@ -414,7 +414,7 @@ def test_dark_launch_enrolled_student(self):
self._check_non_staff_light(self.test_course)
self._check_non_staff_dark(self.test_course)

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_dark_launch_instructor(self):
"""
Make sure that before course start instructors can access the
Expand All @@ -437,7 +437,7 @@ def test_dark_launch_instructor(self):
self._check_non_staff_light(self.test_course)
self._check_non_staff_dark(self.test_course)

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_dark_launch_global_staff(self):
"""
Make sure that before course start staff can access
Expand All @@ -459,7 +459,7 @@ def test_dark_launch_global_staff(self):
self._check_staff(self.course)
self._check_staff(self.test_course)

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_enrollment_period(self):
"""
Check that enrollment periods work.
Expand Down Expand Up @@ -495,7 +495,7 @@ def test_enrollment_period(self):
assert self.enroll(self.course)

@override_waffle_flag(LEGACY_INSTRUCTOR_DASHBOARD, active=True)
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_dark_launch_instructor_legacy(self):
"""
Make sure that before course start instructors can access the
Expand All @@ -518,7 +518,7 @@ def test_dark_launch_instructor_legacy(self):
self._check_non_staff_dark(self.test_course)

@override_waffle_flag(LEGACY_INSTRUCTOR_DASHBOARD, active=True)
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_dark_launch_global_staff_legacy(self):
"""
Make sure that before course start staff can access
Expand Down Expand Up @@ -558,7 +558,7 @@ def setUp(self):
self.normal_student = UserFactory()
self.beta_tester = BetaTesterFactory(course_key=self.course.id) # pylint: disable=no-member

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_course_beta_period(self):
"""
Check that beta-test access works for courses.
Expand All @@ -567,7 +567,7 @@ def test_course_beta_period(self):
self.assertCannotAccessCourse(self.normal_student, 'load', self.course)
self.assertCanAccessCourse(self.beta_tester, 'load', self.course)

@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_content_beta_period(self):
"""
Check that beta-test access works for content.
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,8 @@ class AccessUtilsTestCase(ModuleStoreTestCase):
},
)
@ddt.unpack
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False, 'ENABLE_ENTERPRISE_INTEGRATION': True})
@override_settings(DISABLE_START_DATES=False)
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_ENTERPRISE_INTEGRATION': True})
def test_is_course_open_for_learner(
self,
start_date_modifier,
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from abc import ABCMeta, abstractmethod
from datetime import datetime, timedelta
from unittest.mock import patch
from urllib.parse import urlencode

import ddt
from django.test.utils import override_settings

from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_unenrolled_student(self):
self.setup_user(admin=False, enroll=False, login=True)
self.verify_response(expected_response_code=404)

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_fail_block_unreleased(self):
self.setup_course()
self.setup_user(admin=False, enroll=True, login=True)
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/discussion/rest_api/tests/test_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4197,7 +4197,7 @@ def test_other_providers_ordering_error(self):
)


@mock.patch.dict("django.conf.settings.FEATURES", {"DISABLE_START_DATES": False})
@override_settings(DISABLE_START_DATES=False)
@override_settings(ENABLE_DISCUSSION_SERVICE=True)
class GetCourseTopicsTest(ForumMockUtilsMixin, UrlResetMixin, ModuleStoreTestCase):
"""Test for get_course_topics"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import ddt
import pytest
from django.test.utils import override_settings
from django.urls import reverse
from edx_toggles.toggles.testutils import override_waffle_flag
from freezegun import freeze_time
Expand Down Expand Up @@ -2222,7 +2223,7 @@ def test_with_unauthorized_user(self):

assert status.HTTP_403_FORBIDDEN == resp.status_code

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_get_override_for_unreleased_block(self):
self.login_course_staff()
unreleased_subsection = BlockFactory.create(
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/grades/tests/test_course_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest.mock import patch

import pytest
from django.test.utils import override_settings

from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.course_blocks.api import get_course_blocks
Expand Down Expand Up @@ -88,7 +89,7 @@ def test_no_data(self):
with pytest.raises(ValueError): # noqa: PT011
_ = CourseData(self.user)

@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_full_string(self):
empty_structure = get_course_blocks(self.user, self.course.location)
assert not empty_structure
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor_task/tests/test_tasks_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ def create_course(self):
)
self.define_option_problem('Unreleased', parent=self.unreleased_section)

@patch.dict(settings.FEATURES, {'DISABLE_START_DATES': False})
@override_settings(DISABLE_START_DATES=False)
def test_grade_report(self):
self.submit_student_answer(self.student.username, 'Problem1', ['Option 1'])

Expand Down
Loading
Loading