Fix patches to use proper courseware imports
This commit is contained in:
@@ -395,7 +395,7 @@ class DashboardTest(ModuleStoreTestCase):
|
||||
self.assertIsNone(course_mode_info['days_for_upsell'])
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@patch('courseware.views.index.log.warning')
|
||||
@patch('lms.djangoapps.courseware.views.index.log.warning')
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_PAID_COURSE_REGISTRATION': True})
|
||||
def test_blocked_course_scenario(self, log_warning):
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
|
||||
self.factory = RequestFactory()
|
||||
|
||||
@patch('student.views.management.render_to_response', RENDER_MOCK)
|
||||
@patch('courseware.views.views.render_to_response', RENDER_MOCK)
|
||||
@patch('lms.djangoapps.courseware.views.views.render_to_response', RENDER_MOCK)
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_COURSE_DISCOVERY': False})
|
||||
def test_course_discovery_off(self):
|
||||
"""
|
||||
@@ -216,7 +216,7 @@ class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
|
||||
self.assertIn('<div class="courses no-course-discovery"', response.content)
|
||||
|
||||
@patch('student.views.management.render_to_response', RENDER_MOCK)
|
||||
@patch('courseware.views.views.render_to_response', RENDER_MOCK)
|
||||
@patch('lms.djangoapps.courseware.views.views.render_to_response', RENDER_MOCK)
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_COURSE_DISCOVERY': True})
|
||||
def test_course_discovery_on(self):
|
||||
"""
|
||||
@@ -238,7 +238,7 @@ class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
|
||||
self.assertIn('<div class="courses"', response.content)
|
||||
|
||||
@patch('student.views.management.render_to_response', RENDER_MOCK)
|
||||
@patch('courseware.views.views.render_to_response', RENDER_MOCK)
|
||||
@patch('lms.djangoapps.courseware.views.views.render_to_response', RENDER_MOCK)
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_COURSE_DISCOVERY': False})
|
||||
def test_course_cards_sorted_by_default_sorting(self):
|
||||
response = self.client.get('/')
|
||||
@@ -263,7 +263,7 @@ class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
|
||||
self.assertEqual(context['courses'][2].id, self.course_with_default_start_date.id)
|
||||
|
||||
@patch('student.views.management.render_to_response', RENDER_MOCK)
|
||||
@patch('courseware.views.views.render_to_response', RENDER_MOCK)
|
||||
@patch('lms.djangoapps.courseware.views.views.render_to_response', RENDER_MOCK)
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_COURSE_SORTING_BY_START_DATE': False})
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_COURSE_DISCOVERY': False})
|
||||
def test_course_cards_sorted_by_start_date_disabled(self):
|
||||
@@ -296,7 +296,7 @@ class IndexPageProgramsTests(SiteMixin, ModuleStoreTestCase):
|
||||
def test_get_programs_with_type_called(self):
|
||||
views = [
|
||||
(reverse('root'), 'student.views.management.get_programs_with_type'),
|
||||
(reverse('courses'), 'courseware.views.views.get_programs_with_type'),
|
||||
(reverse('courses'), 'lms.djangoapps.courseware.views.views.get_programs_with_type'),
|
||||
]
|
||||
for url, dotted_path in views:
|
||||
with patch(dotted_path) as mock_get_programs_with_type:
|
||||
|
||||
@@ -505,7 +505,7 @@ class CcxListTest(CcxRestApiTest):
|
||||
self.mstore.update_item(self.course, self.coach.id)
|
||||
|
||||
# case with deprecated master_course_id
|
||||
with mock.patch('courseware.courses.get_course_by_id', autospec=True) as mocked:
|
||||
with mock.patch('lms.djangoapps.courseware.courses.get_course_by_id', autospec=True) as mocked:
|
||||
mocked.return_value.id.deprecated = True
|
||||
resp = self.client.post(self.list_url, data, format='json', HTTP_AUTHORIZATION=getattr(self, auth_attr))
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ class TestCCXProgressChanges(CcxTestCase, LoginEnrollmentTestCase):
|
||||
self.assertEqual(progress_page_due_date, due)
|
||||
|
||||
@patch('ccx.views.render_to_response', intercept_renderer)
|
||||
@patch('courseware.views.views.render_to_response', intercept_renderer)
|
||||
@patch('lms.djangoapps.courseware.views.views.render_to_response', intercept_renderer)
|
||||
@patch.dict('django.conf.settings.FEATURES', {'CUSTOM_COURSES_EDX': True})
|
||||
def test_edit_schedule(self):
|
||||
"""
|
||||
@@ -1114,10 +1114,10 @@ class TestCCXGrades(FieldOverrideTestMixin, SharedModuleStoreTestCase, LoginEnro
|
||||
self.assertEqual(data['HW 03'], '0.25')
|
||||
self.assertEqual(data['HW Avg'], '0.5')
|
||||
|
||||
@patch('courseware.views.views.render_to_response', intercept_renderer)
|
||||
@patch('lms.djangoapps.courseware.views.views.render_to_response', intercept_renderer)
|
||||
def test_student_progress(self):
|
||||
self.course.enable_ccx = True
|
||||
patch_context = patch('courseware.views.views.get_course_with_access')
|
||||
patch_context = patch('lms.djangoapps.courseware.views.views.get_course_with_access')
|
||||
get_course = patch_context.start()
|
||||
get_course.return_value = self.course
|
||||
self.addCleanup(patch_context.stop)
|
||||
|
||||
@@ -215,7 +215,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
|
||||
# Note that self.student now have access to preview mode,
|
||||
# `is_masquerading_as_student == True` means user is staff and is
|
||||
# masquerading as a student.
|
||||
with patch('courseware.access.is_masquerading_as_student') as mock_masquerade:
|
||||
with patch('lms.djangoapps.courseware.access.is_masquerading_as_student') as mock_masquerade:
|
||||
mock_masquerade.return_value = True
|
||||
for user in [self.global_staff, self.course_staff, self.course_instructor, self.student]:
|
||||
self.assertTrue(access.has_staff_access_to_preview_mode(user, course_key))
|
||||
@@ -251,17 +251,17 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
|
||||
overview,
|
||||
chapter,
|
||||
]
|
||||
with patch('courseware.access.in_preview_mode') as mock_preview:
|
||||
with patch('lms.djangoapps.courseware.access.in_preview_mode') as mock_preview:
|
||||
mock_preview.return_value = False
|
||||
for obj in modules:
|
||||
self.assertTrue(bool(access.has_access(self.student, 'load', obj, course_key=self.course.id)))
|
||||
|
||||
with patch('courseware.access.in_preview_mode') as mock_preview:
|
||||
with patch('lms.djangoapps.courseware.access.in_preview_mode') as mock_preview:
|
||||
mock_preview.return_value = True
|
||||
for obj in modules:
|
||||
self.assertFalse(bool(access.has_access(self.student, 'load', obj, course_key=self.course.id)))
|
||||
|
||||
@patch('courseware.access.in_preview_mode', Mock(return_value=True))
|
||||
@patch('lms.djangoapps.courseware.access.in_preview_mode', Mock(return_value=True))
|
||||
def test_has_access_with_preview_mode(self):
|
||||
"""
|
||||
Tests particular user's can access content via has_access in preview mode.
|
||||
@@ -275,7 +275,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
|
||||
self.assertFalse(bool(access.has_access(self.student, 'load', self.course, course_key=self.course.id)))
|
||||
|
||||
# When masquerading is true, user should not be able to access staff content
|
||||
with patch('courseware.access.is_masquerading_as_student') as mock_masquerade:
|
||||
with patch('lms.djangoapps.courseware.access.is_masquerading_as_student') as mock_masquerade:
|
||||
mock_masquerade.return_value = True
|
||||
self.assertFalse(
|
||||
bool(access.has_access(self.global_staff, 'staff', self.course, course_key=self.course.id))
|
||||
@@ -284,7 +284,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
|
||||
bool(access.has_access(self.student, 'staff', self.course, course_key=self.course.id))
|
||||
)
|
||||
|
||||
@patch('courseware.access_utils.in_preview_mode', Mock(return_value=True))
|
||||
@patch('lms.djangoapps.courseware.access_utils.in_preview_mode', Mock(return_value=True))
|
||||
def test_has_access_in_preview_mode_with_group(self):
|
||||
"""
|
||||
Test that a user masquerading as a member of a group sees appropriate content in preview mode.
|
||||
@@ -308,7 +308,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
|
||||
modulestore().update_item(self.course, ModuleStoreEnum.UserID.test)
|
||||
|
||||
# User should not be able to preview when masquerading as student (and not in the group above).
|
||||
with patch('courseware.access.get_user_role') as mock_user_role:
|
||||
with patch('lms.djangoapps.courseware.access.get_user_role') as mock_user_role:
|
||||
mock_user_role.return_value = 'student'
|
||||
self.assertFalse(
|
||||
bool(access.has_access(self.global_staff, 'load', chapter, course_key=self.course.id))
|
||||
@@ -316,7 +316,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
|
||||
|
||||
# Should be able to preview when in staff or instructor role.
|
||||
for mocked_role in ['staff', 'instructor']:
|
||||
with patch('courseware.access.get_user_role') as mock_user_role:
|
||||
with patch('lms.djangoapps.courseware.access.get_user_role') as mock_user_role:
|
||||
mock_user_role.return_value = mocked_role
|
||||
self.assertTrue(
|
||||
bool(access.has_access(self.global_staff, 'load', chapter, course_key=self.course.id))
|
||||
@@ -464,7 +464,10 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
|
||||
|
||||
@ddt.data(None, YESTERDAY, TOMORROW)
|
||||
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch('courseware.access_utils.get_current_request_hostname', Mock(return_value='preview.localhost'))
|
||||
@patch(
|
||||
'lms.djangoapps.courseware.access_utils.get_current_request_hostname',
|
||||
Mock(return_value='preview.localhost')
|
||||
)
|
||||
def test__has_access_descriptor_in_preview_mode(self, start):
|
||||
"""
|
||||
Tests that descriptor has access in preview mode.
|
||||
@@ -484,7 +487,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
|
||||
) # 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})
|
||||
@patch('courseware.access_utils.get_current_request_hostname', Mock(return_value='localhost'))
|
||||
@patch('lms.djangoapps.courseware.access_utils.get_current_request_hostname', Mock(return_value='localhost'))
|
||||
def test__has_access_descriptor_when_not_in_preview_mode(self, start, expected_error_type):
|
||||
"""
|
||||
Tests that descriptor has no access when start date in future & without preview.
|
||||
|
||||
@@ -315,7 +315,7 @@ class CoursesRenderTest(ModuleStoreTestCase):
|
||||
self.assertEqual(course_info, u"<a href='/c4x/edX/toy/asset/handouts_sample_handout.txt'>Sample</a>")
|
||||
|
||||
# Test when render raises an exception
|
||||
with mock.patch('courseware.courses.get_module') as mock_module_render:
|
||||
with mock.patch('lms.djangoapps.courseware.courses.get_module') as mock_module_render:
|
||||
mock_module_render.return_value = mock.MagicMock(
|
||||
render=mock.Mock(side_effect=Exception('Render failed!'))
|
||||
)
|
||||
@@ -329,7 +329,7 @@ class CoursesRenderTest(ModuleStoreTestCase):
|
||||
self.assertEqual(course_about, "A course about toys.")
|
||||
|
||||
# Test when render raises an exception
|
||||
with mock.patch('courseware.courses.get_module') as mock_module_render:
|
||||
with mock.patch('lms.djangoapps.courseware.courses.get_module') as mock_module_render:
|
||||
mock_module_render.return_value = mock.MagicMock(
|
||||
render=mock.Mock(side_effect=Exception('Render failed!'))
|
||||
)
|
||||
|
||||
@@ -471,7 +471,7 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
exam_url = response.get('Location')
|
||||
self.assertRedirects(response, exam_url)
|
||||
|
||||
@patch('courseware.entrance_exams.get_entrance_exam_content', Mock(return_value=None))
|
||||
@patch('lms.djangoapps.courseware.entrance_exams.get_entrance_exam_content', Mock(return_value=None))
|
||||
def test_courseware_page_access_after_passing_entrance_exam(self):
|
||||
"""
|
||||
Test courseware access page after passing entrance exam
|
||||
|
||||
@@ -266,7 +266,7 @@ class ModuleRenderTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
}
|
||||
|
||||
# Patch getmodule to return our mock module
|
||||
with patch('courseware.module_render.load_single_xblock', return_value=self.mock_module):
|
||||
with patch('lms.djangoapps.courseware.module_render.load_single_xblock', return_value=self.mock_module):
|
||||
# call xqueue_callback with our mocked information
|
||||
request = self.request_factory.post(self.callback_url, data)
|
||||
render.xqueue_callback(
|
||||
@@ -288,7 +288,7 @@ class ModuleRenderTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
'xqueue_body': 'hello world',
|
||||
}
|
||||
|
||||
with patch('courseware.module_render.load_single_xblock', return_value=self.mock_module):
|
||||
with patch('lms.djangoapps.courseware.module_render.load_single_xblock', return_value=self.mock_module):
|
||||
# Test with missing xqueue data
|
||||
with self.assertRaises(Http404):
|
||||
request = self.request_factory.post(self.callback_url, {})
|
||||
@@ -818,12 +818,12 @@ class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCas
|
||||
)
|
||||
|
||||
with patch(
|
||||
'courseware.module_render.is_xblock_aside',
|
||||
'lms.djangoapps.courseware.module_render.is_xblock_aside',
|
||||
return_value=is_xblock_aside
|
||||
), patch(
|
||||
'courseware.module_render.get_aside_from_xblock'
|
||||
'lms.djangoapps.courseware.module_render.get_aside_from_xblock'
|
||||
) as mocked_get_aside_from_xblock, patch(
|
||||
"courseware.module_render.webob_to_django_response"
|
||||
'lms.djangoapps.courseware.module_render.webob_to_django_response'
|
||||
) as mocked_webob_to_django_response:
|
||||
render.handle_xblock_callback(
|
||||
request,
|
||||
@@ -900,7 +900,7 @@ class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCas
|
||||
request.session = {}
|
||||
request.user.real_user = GlobalStaffFactory.create()
|
||||
request.user.real_user.masquerade_settings = CourseMasquerade(course.id, user_name="jem")
|
||||
with patch('courseware.module_render.is_masquerading_as_specific_student') as mock_masq:
|
||||
with patch('lms.djangoapps.courseware.module_render.is_masquerading_as_specific_student') as mock_masq:
|
||||
mock_masq.return_value = True
|
||||
response = render.handle_xblock_callback(
|
||||
request,
|
||||
@@ -1823,7 +1823,7 @@ class DetachedXBlock(XBlock):
|
||||
|
||||
|
||||
@patch.dict('django.conf.settings.FEATURES', {'DISPLAY_DEBUG_INFO_TO_STAFF': True, 'DISPLAY_HISTOGRAMS_TO_STAFF': True})
|
||||
@patch('courseware.module_render.has_access', Mock(return_value=True, autospec=True))
|
||||
@patch('lms.djangoapps.courseware.module_render.has_access', Mock(return_value=True, autospec=True))
|
||||
class TestStaffDebugInfo(SharedModuleStoreTestCase):
|
||||
"""Tests to verify that Staff Debug Info panel and histograms are displayed to staff."""
|
||||
|
||||
@@ -1992,7 +1992,7 @@ class TestAnonymousStudentId(SharedModuleStoreTestCase, LoginEnrollmentTestCase)
|
||||
super(TestAnonymousStudentId, self).setUp()
|
||||
self.user = UserFactory()
|
||||
|
||||
@patch('courseware.module_render.has_access', Mock(return_value=True, autospec=True))
|
||||
@patch('lms.djangoapps.courseware.module_render.has_access', Mock(return_value=True, autospec=True))
|
||||
def _get_anonymous_id(self, course_id, xblock_class):
|
||||
location = course_id.make_usage_key('dummy_category', 'dummy_name')
|
||||
descriptor = Mock(
|
||||
@@ -2467,7 +2467,7 @@ class TestFilteredChildren(SharedModuleStoreTestCase):
|
||||
self.users = {number: UserFactory() for number in USER_NUMBERS}
|
||||
|
||||
self._old_has_access = render.has_access
|
||||
patcher = patch('courseware.module_render.has_access', self._has_access)
|
||||
patcher = patch('lms.djangoapps.courseware.module_render.has_access', self._has_access)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class SelfPacedDateOverrideTest(ModuleStoreTestCase):
|
||||
__, sp_section = self.setup_course(display_name="Self-Paced Course", self_paced=True)
|
||||
self.assertIsNone(sp_section.due)
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'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.
|
||||
@@ -113,7 +113,7 @@ class SelfPacedDateOverrideTest(ModuleStoreTestCase):
|
||||
self.assertTrue(has_access(beta_tester, 'load', self_paced_course))
|
||||
self.assertTrue(has_access(beta_tester, 'load', self_paced_section, self_paced_course.id))
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_instructor_paced_discussion_xblock_visibility(self):
|
||||
"""
|
||||
Verify that discussion xblocks scheduled for release in the future are
|
||||
@@ -128,7 +128,7 @@ class SelfPacedDateOverrideTest(ModuleStoreTestCase):
|
||||
all(xblock.display_name == 'released' for xblock in xblocks)
|
||||
)
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_self_paced_discussion_xblock_visibility(self):
|
||||
"""
|
||||
Regression test. Verify that discussion xblocks scheduled for release
|
||||
|
||||
@@ -791,7 +791,7 @@ class ProblemWithUploadedFilesTest(TestSubmittingProblems):
|
||||
self.addCleanup(fileobj.close)
|
||||
|
||||
self.problem_setup("the_problem", filenames)
|
||||
with patch('courseware.module_render.XQUEUE_INTERFACE.session') as mock_session:
|
||||
with patch('lms.djangoapps.courseware.module_render.XQUEUE_INTERFACE.session') as mock_session:
|
||||
resp = self.submit_question_answer("the_problem", {'2_1': fileobjs})
|
||||
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
@@ -282,7 +282,7 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
self.assertIn('static_tab', tab_content)
|
||||
|
||||
# Test when render raises an exception
|
||||
with patch('courseware.views.views.get_module') as mock_module_render:
|
||||
with patch('lms.djangoapps.courseware.views.views.get_module') as mock_module_render:
|
||||
mock_module_render.return_value = MagicMock(
|
||||
render=Mock(side_effect=Exception('Render failed!'))
|
||||
)
|
||||
|
||||
@@ -307,7 +307,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
|
||||
for url in urls:
|
||||
self.assert_request_status_code(200, url)
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_dark_launch_enrolled_student(self):
|
||||
"""
|
||||
Make sure that before course start, students can't access course
|
||||
@@ -334,7 +334,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
|
||||
self._check_non_staff_light(self.test_course)
|
||||
self._check_non_staff_dark(self.test_course)
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_dark_launch_instructor(self):
|
||||
"""
|
||||
Make sure that before course start instructors can access the
|
||||
@@ -357,7 +357,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
|
||||
self._check_non_staff_light(self.test_course)
|
||||
self._check_non_staff_dark(self.test_course)
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_dark_launch_global_staff(self):
|
||||
"""
|
||||
Make sure that before course start staff can access
|
||||
@@ -379,7 +379,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
|
||||
self._check_staff(self.course)
|
||||
self._check_staff(self.test_course)
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_enrollment_period(self):
|
||||
"""
|
||||
Check that enrollment periods work.
|
||||
@@ -432,7 +432,7 @@ class TestBetatesterAccess(ModuleStoreTestCase, CourseAccessTestMixin):
|
||||
self.normal_student = UserFactory()
|
||||
self.beta_tester = BetaTesterFactory(course_key=self.course.id)
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_course_beta_period(self):
|
||||
"""
|
||||
Check that beta-test access works for courses.
|
||||
@@ -441,7 +441,7 @@ class TestBetatesterAccess(ModuleStoreTestCase, CourseAccessTestMixin):
|
||||
self.assertCannotAccessCourse(self.normal_student, 'load', self.course)
|
||||
self.assertCanAccessCourse(self.beta_tester, 'load', self.course)
|
||||
|
||||
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
@patch.dict('lms.djangoapps.courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_content_beta_period(self):
|
||||
"""
|
||||
Check that beta-test access works for content.
|
||||
|
||||
@@ -347,7 +347,7 @@ class ViewsTestCase(ModuleStoreTestCase):
|
||||
self._verify_index_response(expected_response_code=404, chapter_name='non-existent')
|
||||
|
||||
def test_index_nonexistent_chapter_masquerade(self):
|
||||
with patch('courseware.views.index.setup_masquerade') as patch_masquerade:
|
||||
with patch('lms.djangoapps.courseware.views.index.setup_masquerade') as patch_masquerade:
|
||||
masquerade = MagicMock(role='student')
|
||||
patch_masquerade.return_value = (masquerade, self.user)
|
||||
self._verify_index_response(expected_response_code=302, chapter_name='non-existent')
|
||||
@@ -356,7 +356,7 @@ class ViewsTestCase(ModuleStoreTestCase):
|
||||
self._verify_index_response(expected_response_code=404, section_name='non-existent')
|
||||
|
||||
def test_index_nonexistent_section_masquerade(self):
|
||||
with patch('courseware.views.index.setup_masquerade') as patch_masquerade:
|
||||
with patch('lms.djangoapps.courseware.views.index.setup_masquerade') as patch_masquerade:
|
||||
masquerade = MagicMock(role='student')
|
||||
patch_masquerade.return_value = (masquerade, self.user)
|
||||
self._verify_index_response(expected_response_code=302, section_name='non-existent')
|
||||
@@ -1700,7 +1700,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
bannerText = get_expiration_banner_text(user, self.course)
|
||||
self.assertNotContains(response, bannerText, html=True)
|
||||
|
||||
@patch('courseware.views.views.is_course_passed', PropertyMock(return_value=True))
|
||||
@patch('lms.djangoapps.courseware.views.views.is_course_passed', PropertyMock(return_value=True))
|
||||
@patch('lms.djangoapps.certificates.api.get_active_web_certificate', PropertyMock(return_value=True))
|
||||
@override_settings(FEATURES=FEATURES_WITH_DISABLE_HONOR_CERTIFICATE)
|
||||
@ddt.data(CourseMode.AUDIT, CourseMode.HONOR)
|
||||
@@ -2184,14 +2184,14 @@ class GenerateUserCertTests(ModuleStoreTestCase):
|
||||
self.assertEqual(resp.status_code, HttpResponseBadRequest.status_code)
|
||||
self.assertIn("Your certificate will be available when you pass the course.", resp.content)
|
||||
|
||||
@patch('courseware.views.views.is_course_passed', return_value=True)
|
||||
@patch('lms.djangoapps.courseware.views.views.is_course_passed', return_value=True)
|
||||
@override_settings(CERT_QUEUE='certificates', LMS_SEGMENT_KEY="foobar")
|
||||
def test_user_with_passing_grade(self, mock_is_course_passed):
|
||||
# If user has above passing grading then json will return cert generating message and
|
||||
# status valid code
|
||||
# mocking xqueue and Segment analytics
|
||||
|
||||
analytics_patcher = patch('courseware.views.views.segment')
|
||||
analytics_patcher = patch('lms.djangoapps.courseware.views.views.segment')
|
||||
mock_tracker = analytics_patcher.start()
|
||||
self.addCleanup(analytics_patcher.stop)
|
||||
|
||||
@@ -2465,7 +2465,7 @@ class TestIndexView(ModuleStoreTestCase):
|
||||
self.assertIn('xblock-student_view-html', unicode_content)
|
||||
self.assertIn('xblock-student_view-video', unicode_content)
|
||||
|
||||
@patch('courseware.views.views.CourseTabView.course_open_for_learner_enrollment')
|
||||
@patch('lms.djangoapps.courseware.views.views.CourseTabView.course_open_for_learner_enrollment')
|
||||
@patch('openedx.core.djangoapps.util.user_messages.PageLevelMessages.register_warning_message')
|
||||
def test_courseware_messages_differentiate_for_anonymous_users(
|
||||
self, patch_register_warning_message, patch_course_open_for_learner_enrollment
|
||||
@@ -2496,7 +2496,7 @@ class TestIndexView(ModuleStoreTestCase):
|
||||
@patch('openedx.core.djangoapps.util.user_messages.PageLevelMessages.register_warning_message')
|
||||
def test_courseware_messages_masters_only(self, patch_register_warning_message):
|
||||
with patch(
|
||||
'courseware.views.views.CourseTabView.course_open_for_learner_enrollment'
|
||||
'lms.djangoapps.courseware.views.views.CourseTabView.course_open_for_learner_enrollment'
|
||||
) as patch_course_open_for_learner_enrollment:
|
||||
course = CourseFactory()
|
||||
|
||||
@@ -2535,7 +2535,8 @@ class TestIndexView(ModuleStoreTestCase):
|
||||
@ddt.unpack
|
||||
def test_should_show_enroll_button(self, course_open_for_self_enrollment,
|
||||
invitation_only, is_masters_only, expected_should_show_enroll_button):
|
||||
with patch('courseware.views.views.course_open_for_self_enrollment') as patch_course_open_for_self_enrollment, \
|
||||
with patch('lms.djangoapps.courseware.views.views.course_open_for_self_enrollment') \
|
||||
as patch_course_open_for_self_enrollment, \
|
||||
patch('course_modes.models.CourseMode.is_masters_only') as patch_is_masters_only:
|
||||
course = CourseFactory()
|
||||
|
||||
@@ -2994,7 +2995,7 @@ class TestIndexViewCrawlerStudentStateWrites(SharedModuleStoreTestCase):
|
||||
|
||||
def test_write_by_default(self):
|
||||
"""By default, always write student state, regardless of user agent."""
|
||||
with patch('courseware.model_data.UserStateCache.set_many') as patched_state_client_set_many:
|
||||
with patch('lms.djangoapps.courseware.model_data.UserStateCache.set_many') as patched_state_client_set_many:
|
||||
# Simulate someone using Chrome
|
||||
self._load_courseware('Mozilla/5.0 AppleWebKit/537.36')
|
||||
self.assertTrue(patched_state_client_set_many.called)
|
||||
@@ -3007,7 +3008,7 @@ class TestIndexViewCrawlerStudentStateWrites(SharedModuleStoreTestCase):
|
||||
def test_writes_with_config(self):
|
||||
"""Test state writes (or lack thereof) based on config values."""
|
||||
CrawlersConfig.objects.create(known_user_agents='edX-downloader,crawler_foo', enabled=True)
|
||||
with patch('courseware.model_data.UserStateCache.set_many') as patched_state_client_set_many:
|
||||
with patch('lms.djangoapps.courseware.model_data.UserStateCache.set_many') as patched_state_client_set_many:
|
||||
# Exact matching of crawler user agent
|
||||
self._load_courseware('crawler_foo')
|
||||
self.assertFalse(patched_state_client_set_many.called)
|
||||
|
||||
@@ -488,7 +488,7 @@ class TestResetAttemptsTask(TestIntegrationTask):
|
||||
self.submit_student_answer('u1', problem_url_name, [OPTION_1, OPTION_1])
|
||||
|
||||
expected_message = "bad things happened"
|
||||
with patch('courseware.models.StudentModule.save') as mock_save:
|
||||
with patch('lms.djangoapps.courseware.models.StudentModule.save') as mock_save:
|
||||
mock_save.side_effect = ZeroDivisionError(expected_message)
|
||||
instructor_task = self.reset_problem_attempts('instructor', location)
|
||||
self._assert_task_failure(instructor_task.id, 'reset_problem_attempts', problem_url_name, expected_message)
|
||||
@@ -550,7 +550,7 @@ class TestDeleteProblemTask(TestIntegrationTask):
|
||||
self.submit_student_answer('u1', problem_url_name, [OPTION_1, OPTION_1])
|
||||
|
||||
expected_message = "bad things happened"
|
||||
with patch('courseware.models.StudentModule.delete') as mock_delete:
|
||||
with patch('lms.djangoapps.courseware.models.StudentModule.delete') as mock_delete:
|
||||
mock_delete.side_effect = ZeroDivisionError(expected_message)
|
||||
instructor_task = self.delete_problem_state('instructor', location)
|
||||
self._assert_task_failure(instructor_task.id, 'delete_problem_state', problem_url_name, expected_message)
|
||||
|
||||
Reference in New Issue
Block a user