diff --git a/cms/djangoapps/contentstore/tests/test_proctoring.py b/cms/djangoapps/contentstore/tests/test_proctoring.py index 76437f7b5c..37f2e3072b 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 cb4d604e69..73497824d5 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,14 +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}') + result = export_olx.delay(user.id, key, 'en') + self._assert_failed(result, f'Unknown User ID: {user.id}') def test_non_course_author(self): """ 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 d2b22ce362..7cecac8cbd 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