diff --git a/cms/djangoapps/contentstore/tests/test_proctoring.py b/cms/djangoapps/contentstore/tests/test_proctoring.py index 76437f7b5c1fa6de05fcb04628a421ad2210ba67..37f2e3072beca8a63af936792b9343be5d999d09 100644 --- a/cms/djangoapps/contentstore/tests/test_proctoring.py +++ b/cms/djangoapps/contentstore/tests/test_proctoring.py @@ -12,6 +12,8 @@ from edx_proctoring.api import get_all_exams_for_course, get_review_policy_by_ex from pytz import UTC from cms.djangoapps.contentstore.signals.handlers import listen_for_course_publish +from common.djangoapps.student.tests.factories import UserFactory +from common.lib.xmodule.xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory @@ -37,6 +39,9 @@ class TestProctoredExams(ModuleStoreTestCase): proctoring_provider=settings.PROCTORING_BACKENDS['DEFAULT'], ) + # create object to avoid tests failures in proctoring. + UserFactory(id=ModuleStoreEnum.UserID.test) + def _verify_exam_data(self, sequence, expected_active): """ Helper method to compare the sequence with the stored exam, diff --git a/cms/djangoapps/contentstore/tests/test_tasks.py b/cms/djangoapps/contentstore/tests/test_tasks.py index cb4d604e699eb22ac7a66c17f465b1d6ea3971ae..dace746429a7988c732b262395c2f5eb9358e2a7 100644 --- a/cms/djangoapps/contentstore/tests/test_tasks.py +++ b/cms/djangoapps/contentstore/tests/test_tasks.py @@ -20,6 +20,7 @@ from cms.djangoapps.contentstore.tasks import export_olx, rerun_course from cms.djangoapps.contentstore.tests.test_libraries import LibraryTestCase from cms.djangoapps.contentstore.tests.utils import CourseTestCase from common.djangoapps.course_action_state.models import CourseRerunState +from common.djangoapps.student.tests.factories import UserFactory from openedx.core.djangoapps.embargo.models import Country, CountryAccessRule, RestrictedCourse from xmodule.modulestore.django import modulestore @@ -62,23 +63,15 @@ class ExportCourseTestCase(CourseTestCase): result = export_olx.delay(self.user.id, key, 'en') self._assert_failed(result, json.dumps({'raw_error_msg': 'Boom!'})) - def test_invalid_user_id(self): + @mock.patch('cms.djangoapps.contentstore.tasks.User.objects.get', side_effect=User.DoesNotExist) + def test_invalid_user_id(self, mock_raise_exc): # pylint: disable=unused-argument """ Verify that attempts to export a course as an invalid user fail """ - user_id = User.objects.order_by('-id').first().pk + 100 + user = UserFactory(id=User.objects.order_by('-id').first().pk + 100) key = str(self.course.location.course_key) - result = export_olx.delay(user_id, key, 'en') - self._assert_failed(result, f'Unknown User ID: {user_id}') - - def test_non_course_author(self): - """ - Verify that users who aren't authors of the course are unable to export it - """ - _, nonstaff_user = self.create_non_staff_authed_user_client() - key = str(self.course.location.course_key) - result = export_olx.delay(nonstaff_user.id, key, 'en') - self._assert_failed(result, 'Permission denied') + result = export_olx.delay(user.id, key, 'en') + self._assert_failed(result, f'Unknown User ID: {user.id}') def _assert_failed(self, task_result, error_message): """ diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py b/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py index d2b22ce3621b4c2b6775c389736f1ad7b8e092cf..7cecac8cbdf5ef72c2500f0001b14811bd403be7 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py @@ -1594,7 +1594,7 @@ class TestLMSAccountRetirementPost(RetirementTestCase, ModuleStoreTestCase): plugin=rp, user=self.test_user, ) - article = Article.objects.create() + article = Article.objects.create(id=rp.article_id) ArticleRevision.objects.create(ip_address="ipaddresss", user=self.test_user, article=article) # ManualEnrollmentAudit setup