diff --git a/cms/djangoapps/contentstore/tests/test_upstream_downstream_links.py b/cms/djangoapps/contentstore/tests/test_upstream_downstream_links.py index e604735fc354..f649299d560b 100644 --- a/cms/djangoapps/contentstore/tests/test_upstream_downstream_links.py +++ b/cms/djangoapps/contentstore/tests/test_upstream_downstream_links.py @@ -10,7 +10,7 @@ from django.test import TestCase from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locator import LibraryContainerLocator, LibraryUsageLocatorV2 -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from common.djangoapps.student.tests.factories import UserFactory from openedx.core.djangolib.testing.utils import skip_unless_cms diff --git a/cms/djangoapps/contentstore/tests/test_utils.py b/cms/djangoapps/contentstore/tests/test_utils.py index 83edcb87e0c7..85e694f02e24 100644 --- a/cms/djangoapps/contentstore/tests/test_utils.py +++ b/cms/djangoapps/contentstore/tests/test_utils.py @@ -11,7 +11,7 @@ from django.test.utils import override_settings from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locator import CourseLocator, LibraryLocator -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from path import Path as path from pytz import UTC from rest_framework import status diff --git a/cms/djangoapps/contentstore/views/tests/test_block.py b/cms/djangoapps/contentstore/views/tests/test_block.py index 2b99dbb4eb7b..d3a5951502ce 100644 --- a/cms/djangoapps/contentstore/views/tests/test_block.py +++ b/cms/djangoapps/contentstore/views/tests/test_block.py @@ -21,7 +21,7 @@ from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator from openedx_events.content_authoring.data import DuplicatedXBlockData from openedx_events.content_authoring.signals import XBLOCK_DUPLICATED -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from pytz import UTC from web_fragments.fragment import Fragment from webob import Response @@ -743,7 +743,7 @@ def _duplicate_item(self, parent_usage_key, source_usage_key, display_name=None) return self.response_usage_key(resp) -class TestDuplicateItem(ItemTest, DuplicateHelper, OpenEdxEventsTestMixin): +class TestDuplicateItem(OpenEdxEventsTestMixin, ItemTest, DuplicateHelper): """ Test the duplicate method. """ @@ -752,22 +752,6 @@ class TestDuplicateItem(ItemTest, DuplicateHelper, OpenEdxEventsTestMixin): "org.openedx.content_authoring.xblock.duplicated.v1", ] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - - @classmethod - def tearDownClass(cls): - """ Don't let our event isolation affect other test cases """ - super().tearDownClass() - cls.enable_all_events() # Re-enable events other than the ENABLED_OPENEDX_EVENTS subset we isolated. - def setUp(self): """Creates the test course structure and a few components to 'duplicate'.""" super().setUp() diff --git a/cms/djangoapps/contentstore/views/tests/test_clipboard_paste.py b/cms/djangoapps/contentstore/views/tests/test_clipboard_paste.py index 8b7ba2225f44..1430bbc4dc65 100644 --- a/cms/djangoapps/contentstore/views/tests/test_clipboard_paste.py +++ b/cms/djangoapps/contentstore/views/tests/test_clipboard_paste.py @@ -11,7 +11,7 @@ XBLOCK_DELETED, XBLOCK_UPDATED, ) -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from openedx_tagging.models import Tag from organizations.models import Organization from rest_framework.test import APIClient diff --git a/common/djangoapps/student/tests/test_enrollment.py b/common/djangoapps/student/tests/test_enrollment.py index 767479ac2756..b7f480a8945f 100644 --- a/common/djangoapps/student/tests/test_enrollment.py +++ b/common/djangoapps/student/tests/test_enrollment.py @@ -8,7 +8,7 @@ import pytest from django.conf import settings from django.urls import reverse -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.tests.factories import CourseModeFactory @@ -30,7 +30,7 @@ @ddt.ddt @patch.dict('django.conf.settings.FEATURES', {'ENABLE_SPECIAL_EXAMS': True}) @skip_unless_lms -class EnrollmentTest(UrlResetMixin, ModuleStoreTestCase, OpenEdxEventsTestMixin): +class EnrollmentTest(OpenEdxEventsTestMixin, UrlResetMixin, ModuleStoreTestCase): """ Test student enrollment, especially with different course modes. """ @@ -42,17 +42,6 @@ class EnrollmentTest(UrlResetMixin, ModuleStoreTestCase, OpenEdxEventsTestMixin) PASSWORD = "edx" URLCONF_MODULES = ['openedx.core.djangoapps.embargo'] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - @patch.dict(settings.FEATURES, {'EMBARGO': True}) def setUp(self): """ Create a course and user, then log in. """ diff --git a/common/djangoapps/student/tests/test_events.py b/common/djangoapps/student/tests/test_events.py index e60d2f544810..c6f9ff299c26 100644 --- a/common/djangoapps/student/tests/test_events.py +++ b/common/djangoapps/student/tests/test_events.py @@ -25,7 +25,7 @@ COURSE_ENROLLMENT_CREATED, COURSE_UNENROLLMENT_COMPLETED, ) -from openedx_events.tests.utils import OpenEdxEventsTestMixin # lint-amnesty, pylint: disable=wrong-import-order +from openedx_events.testing import OpenEdxEventsTestMixin # lint-amnesty, pylint: disable=wrong-import-order from common.djangoapps.student.models import CourseEnrollment, CourseEnrollmentAllowed from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRole @@ -211,7 +211,7 @@ def test_enrolled_after_email_change(self): @skip_unless_lms -class EnrollmentEventsTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class EnrollmentEventsTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Tests for the Open edX Events associated with the enrollment process through the enroll method. @@ -229,17 +229,6 @@ class EnrollmentEventsTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): "org.openedx.learning.course.unenrollment.completed.v1", ] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): # pylint: disable=arguments-differ super().setUp() self.course = CourseFactory.create() @@ -391,7 +380,7 @@ def test_unenrollment_completed_event_emitted(self): @skip_unless_lms @ddt.ddt -class TestCourseAccessRoleEvents(TestCase, OpenEdxEventsTestMixin): +class TestCourseAccessRoleEvents(OpenEdxEventsTestMixin, TestCase): """ Tests for the events associated with the CourseAccessRole model. """ @@ -400,11 +389,6 @@ class TestCourseAccessRoleEvents(TestCase, OpenEdxEventsTestMixin): 'org.openedx.learning.user.course_access_role.removed.v1', ] - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.start_events_isolation() - def setUp(self): self.course_key = CourseKey.from_string("course-v1:test+blah+blah") self.user = UserFactory.create( diff --git a/lms/djangoapps/certificates/tests/test_events.py b/lms/djangoapps/certificates/tests/test_events.py index 3d241c30676a..91e68dff4385 100644 --- a/lms/djangoapps/certificates/tests/test_events.py +++ b/lms/djangoapps/certificates/tests/test_events.py @@ -9,7 +9,7 @@ from openedx_events.learning.data import CertificateData, CourseData, UserData, UserPersonalData from openedx_events.learning.signals import CERTIFICATE_CHANGED, CERTIFICATE_CREATED, CERTIFICATE_REVOKED -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from common.djangoapps.student.tests.factories import UserFactory from common.test.utils import assert_dict_contains_subset @@ -23,7 +23,7 @@ @skip_unless_lms -class CertificateEventTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class CertificateEventTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Tests for the Open edX Events associated with the student's certification process. @@ -43,17 +43,6 @@ class CertificateEventTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): "org.openedx.learning.certificate.revoked.v1", ] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): # pylint: disable=arguments-differ super().setUp() self.course = CourseOverviewFactory() diff --git a/lms/djangoapps/certificates/tests/test_filters.py b/lms/djangoapps/certificates/tests/test_filters.py index e483aba55adb..e20752177333 100644 --- a/lms/djangoapps/certificates/tests/test_filters.py +++ b/lms/djangoapps/certificates/tests/test_filters.py @@ -71,9 +71,13 @@ class CertificateFiltersTest(SharedModuleStoreTestCase): - CertificateCreationRequested """ + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.course_run = CourseFactory() + def setUp(self): # pylint: disable=arguments-differ super().setUp() - self.course_run = CourseFactory() self.user = UserFactory.create( username="somestudent", first_name="Student", diff --git a/lms/djangoapps/certificates/tests/test_models.py b/lms/djangoapps/certificates/tests/test_models.py index c3b835d7ffd2..526b9a8f9392 100644 --- a/lms/djangoapps/certificates/tests/test_models.py +++ b/lms/djangoapps/certificates/tests/test_models.py @@ -13,7 +13,7 @@ from django.test import TestCase from django.test.utils import override_settings from opaque_keys.edx.locator import CourseKey, CourseLocator -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from path import Path as path from common.djangoapps.course_modes.models import CourseMode @@ -57,7 +57,7 @@ name_affirmation_service = get_name_affirmation_service() -class ExampleCertificateTest(TestCase, OpenEdxEventsTestMixin): +class ExampleCertificateTest(OpenEdxEventsTestMixin, TestCase): """Tests for the ExampleCertificate model. """ COURSE_KEY = CourseLocator(org='test', course='test', run='test') @@ -69,17 +69,6 @@ class ExampleCertificateTest(TestCase, OpenEdxEventsTestMixin): ENABLED_OPENEDX_EVENTS = [] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.cert_set = ExampleCertificateSet.objects.create(course_key=self.COURSE_KEY) @@ -127,24 +116,13 @@ def test_latest_status_is_course_specific(self): assert result is None -class CertificateHtmlViewConfigurationTest(TestCase, OpenEdxEventsTestMixin): +class CertificateHtmlViewConfigurationTest(OpenEdxEventsTestMixin, TestCase): """ Test the CertificateHtmlViewConfiguration model. """ ENABLED_OPENEDX_EVENTS = [] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.configuration_string = """{ @@ -234,7 +212,7 @@ def test_asset_file_saving_with_actual_name(self): assert certificate_template_asset.asset == 'certificate_template_assets/1/picture2.jpg' -class EligibleCertificateManagerTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class EligibleCertificateManagerTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Test the GeneratedCertificate model's object manager for filtering out ineligible certs. @@ -242,17 +220,6 @@ class EligibleCertificateManagerTest(SharedModuleStoreTestCase, OpenEdxEventsTes ENABLED_OPENEDX_EVENTS = [] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.user = UserFactory() @@ -292,24 +259,13 @@ def test_filter_certificates_for_nonexistent_courses(self): @ddt.ddt -class TestCertificateGenerationHistory(TestCase, OpenEdxEventsTestMixin): +class TestCertificateGenerationHistory(OpenEdxEventsTestMixin, TestCase): """ Test the CertificateGenerationHistory model's methods """ ENABLED_OPENEDX_EVENTS = [] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - @ddt.data( ({"student_set": "allowlisted_not_generated"}, "For exceptions", True), ({"student_set": "allowlisted_not_generated"}, "For exceptions", False), @@ -364,7 +320,7 @@ def test_get_task_name(self, is_regeneration, expected): assert certificate_generation_history.get_task_name() == expected -class CertificateInvalidationTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class CertificateInvalidationTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Test for the Certificate Invalidation model. """ @@ -373,18 +329,11 @@ class CertificateInvalidationTest(SharedModuleStoreTestCase, OpenEdxEventsTestMi @classmethod def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ super().setUpClass() - cls.start_events_isolation() + cls.course = CourseFactory() def setUp(self): super().setUp() - self.course = CourseFactory() self.course_overview = CourseOverviewFactory.create( id=self.course.id ) @@ -434,24 +383,13 @@ def test_revoke_program_certificates(self, mock_issuance, mock_revoke_task): @ddt.ddt -class GeneratedCertificateTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class GeneratedCertificateTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Test GeneratedCertificates """ ENABLED_OPENEDX_EVENTS = [] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.user = UserFactory() @@ -691,7 +629,7 @@ def test_unverified(self, mock_emit_certificate_event): self._assert_event_data(mock_emit_certificate_event, expected_event_data) -class CertificateAllowlistTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class CertificateAllowlistTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Tests for the CertificateAllowlist model. """ @@ -700,14 +638,8 @@ class CertificateAllowlistTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin @classmethod def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ super().setUpClass() - cls.start_events_isolation() + cls.course_run = CourseFactory() def setUp(self): super().setUp() @@ -716,7 +648,6 @@ def setUp(self): self.user = UserFactory(username=self.username, email=self.user_email) self.second_user = UserFactory() - self.course_run = CourseFactory() self.course_run_key = self.course_run.id # pylint: disable=no-member def test_get_allowlist_empty(self): diff --git a/lms/djangoapps/certificates/tests/test_signals.py b/lms/djangoapps/certificates/tests/test_signals.py index 774c43118095..aff475c8e965 100644 --- a/lms/djangoapps/certificates/tests/test_signals.py +++ b/lms/djangoapps/certificates/tests/test_signals.py @@ -13,7 +13,7 @@ from openedx_events.data import EventsMetadata from openedx_events.learning.data import ExamAttemptData, UserData, UserPersonalData from openedx_events.learning.signals import EXAM_ATTEMPT_REJECTED -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from lms.djangoapps.certificates.api import has_self_generated_certificates_enabled @@ -300,17 +300,12 @@ def test_failing_grade_allowlist(self): assert cert.status == CertificateStatuses.downloadable -class LearnerIdVerificationTest(ModuleStoreTestCase, OpenEdxEventsTestMixin): +class LearnerIdVerificationTest(OpenEdxEventsTestMixin, ModuleStoreTestCase): """ Tests for certificate generation task firing on learner id verification """ ENABLED_OPENEDX_EVENTS = ['org.openedx.learning.idv_attempt.approved.v1'] - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.course_one = CourseFactory.create(self_paced=True) diff --git a/lms/djangoapps/grades/tests/test_events.py b/lms/djangoapps/grades/tests/test_events.py index 36096c1a200b..01b214ce95e1 100644 --- a/lms/djangoapps/grades/tests/test_events.py +++ b/lms/djangoapps/grades/tests/test_events.py @@ -20,7 +20,7 @@ COURSE_PASSING_STATUS_UPDATED, PERSISTENT_GRADE_SUMMARY_CHANGED, ) -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from common.djangoapps.student.tests.factories import AdminFactory, UserFactory from common.test.utils import assert_dict_contains_subset @@ -32,7 +32,7 @@ from xmodule.modulestore.tests.factories import CourseFactory -class PersistentGradeEventsTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class PersistentGradeEventsTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Tests for the Open edX Events associated with the persistant grade process through the update_or_create method. @@ -45,17 +45,6 @@ class PersistentGradeEventsTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixi "org.openedx.learning.course.persistent_grade_summary.changed.v1", ] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): # pylint: disable=arguments-differ super().setUp() self.course = CourseFactory.create() @@ -113,7 +102,7 @@ def test_persistent_grade_event_emitted(self): ) -class CoursePassingStatusEventsTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class CoursePassingStatusEventsTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Tests for Open edX passing status update event. """ @@ -121,14 +110,6 @@ class CoursePassingStatusEventsTest(SharedModuleStoreTestCase, OpenEdxEventsTest "org.openedx.learning.course.passing.status.updated.v1", ] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.course = CourseFactory.create() @@ -179,7 +160,7 @@ def test_course_passing_status_updated_emitted(self): class CCXCoursePassingStatusEventsTest( - SharedModuleStoreTestCase, OpenEdxEventsTestMixin + OpenEdxEventsTestMixin, SharedModuleStoreTestCase ): """ Tests for Open edX passing status update event in a CCX course. @@ -188,14 +169,6 @@ class CCXCoursePassingStatusEventsTest( "org.openedx.learning.ccx.course.passing.status.updated.v1", ] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.course = CourseFactory.create() diff --git a/openedx/core/djangoapps/course_groups/tests/test_cohorts.py b/openedx/core/djangoapps/course_groups/tests/test_cohorts.py index 1873e00769e9..8d676f09e910 100644 --- a/openedx/core/djangoapps/course_groups/tests/test_cohorts.py +++ b/openedx/core/djangoapps/course_groups/tests/test_cohorts.py @@ -13,7 +13,7 @@ from django.test import TestCase from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locator import CourseLocator -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.tests.factories import UserFactory @@ -30,30 +30,13 @@ @patch("openedx.core.djangoapps.course_groups.cohorts.tracker", autospec=True) -class TestCohortSignals(TestCase, OpenEdxEventsTestMixin): +class TestCohortSignals(OpenEdxEventsTestMixin, TestCase): """ Test cases to validate event emissions for various cohort-related workflows """ ENABLED_OPENEDX_EVENTS = [] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - - @classmethod - def tearDownClass(cls): - """ Don't let our event isolation affect other test cases """ - super().tearDownClass() - cls.enable_all_events() # Re-enable events other than the ENABLED_OPENEDX_EVENTS subset we isolated. - def setUp(self): super().setUp() self.course_key = CourseLocator("dummy", "dummy", "dummy") diff --git a/openedx/core/djangoapps/course_groups/tests/test_events.py b/openedx/core/djangoapps/course_groups/tests/test_events.py index b86406b4a98f..adaa98697cca 100644 --- a/openedx/core/djangoapps/course_groups/tests/test_events.py +++ b/openedx/core/djangoapps/course_groups/tests/test_events.py @@ -15,7 +15,7 @@ from openedx_events.learning.signals import ( COHORT_MEMBERSHIP_CHANGED, # lint-amnesty, pylint: disable=wrong-import-order ) -from openedx_events.tests.utils import OpenEdxEventsTestMixin # lint-amnesty, pylint: disable=wrong-import-order +from openedx_events.testing import OpenEdxEventsTestMixin # lint-amnesty, pylint: disable=wrong-import-order from common.djangoapps.student.tests.factories import UserFactory from common.test.utils import assert_dict_contains_subset @@ -29,7 +29,7 @@ @skip_unless_lms -class CohortEventTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class CohortEventTest(OpenEdxEventsTestMixin, SharedModuleStoreTestCase): """ Tests for the Open edX Events associated with the cohort update process. @@ -43,23 +43,6 @@ class CohortEventTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): "org.openedx.learning.cohort_membership.changed.v1", ] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - - @classmethod - def tearDownClass(cls): - """ Don't let our event isolation affect other test cases """ - super().tearDownClass() - cls.enable_all_events() # Re-enable events other than the ENABLED_OPENEDX_EVENTS subset we isolated. - def setUp(self): # pylint: disable=arguments-differ super().setUp() self.course = CourseOverviewFactory() diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_events.py b/openedx/core/djangoapps/user_authn/views/tests/test_events.py index 0fea686b1a0d..ebf6577d5f03 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_events.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_events.py @@ -13,7 +13,7 @@ from django.urls import reverse from openedx_events.learning.data import UserData, UserPersonalData from openedx_events.learning.signals import SESSION_LOGIN_COMPLETED, STUDENT_REGISTRATION_COMPLETED -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from common.djangoapps.student.tests.factories import UserFactory, UserProfileFactory from common.test.utils import assert_dict_contains_subset @@ -22,7 +22,7 @@ @skip_unless_lms -class RegistrationEventTest(UserAPITestCase, OpenEdxEventsTestMixin): +class RegistrationEventTest(OpenEdxEventsTestMixin, UserAPITestCase): """ Tests for the Open edX Events associated with the registration process through the registration view. @@ -36,19 +36,6 @@ class RegistrationEventTest(UserAPITestCase, OpenEdxEventsTestMixin): ENABLED_OPENEDX_EVENTS = ["org.openedx.learning.student.registration.completed.v1"] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - So the Open edX Events Isolation starts, the setUpClass must be explicitly - called with the method that executes the isolation. We do this to avoid - MRO resolution conflicts with other sibling classes while ensuring the - isolation process begins. - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): # pylint: disable=arguments-differ super().setUp() self.url = reverse("user_api_registration") @@ -104,7 +91,7 @@ def test_send_registration_event(self): @skip_unless_lms -class LoginSessionEventTest(UserAPITestCase, OpenEdxEventsTestMixin): +class LoginSessionEventTest(OpenEdxEventsTestMixin, UserAPITestCase): """ Tests for the Open edX Events associated with the login process through the login_user view. @@ -118,17 +105,6 @@ class LoginSessionEventTest(UserAPITestCase, OpenEdxEventsTestMixin): ENABLED_OPENEDX_EVENTS = ["org.openedx.learning.auth.session.login.completed.v1"] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): # pylint: disable=arguments-differ super().setUp() self.url = reverse("user_api_login_session", kwargs={"api_version": "v1"}) diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_login.py b/openedx/core/djangoapps/user_authn/views/tests/test_login.py index e57552183deb..b87b51dd25d2 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_login.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_login.py @@ -21,7 +21,7 @@ from django.urls import NoReverseMatch, reverse from edx_toggles.toggles.testutils import override_waffle_switch from freezegun import freeze_time -from openedx_events.tests.utils import OpenEdxEventsTestMixin # lint-amnesty, pylint: disable=wrong-import-order +from openedx_events.testing import OpenEdxEventsTestMixin # lint-amnesty, pylint: disable=wrong-import-order from common.djangoapps.student.models import LoginFailures from common.djangoapps.student.tests.factories import RegistrationFactory, UserFactory, UserProfileFactory @@ -53,7 +53,7 @@ ENABLE_AUTHN_LOGIN_BLOCK_HIBP_POLICY=False, ENABLE_AUTHN_LOGIN_NUDGE_HIBP_POLICY=False, ) -class LoginTest(SiteMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin): +class LoginTest(OpenEdxEventsTestMixin, SiteMixin, CacheIsolationTestCase): """ Test login_user() view """ @@ -67,17 +67,6 @@ class LoginTest(SiteMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin): user_email = 'test@edx.org' password = 'test_password' - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): """Setup a test user along with its registration and profile""" super().setUp() @@ -1046,7 +1035,7 @@ def test_check_user_auth_flow_bad_email(self): @ddt.ddt @skip_unless_lms -class LoginSessionViewTest(ApiTestCase, OpenEdxEventsTestMixin): +class LoginSessionViewTest(OpenEdxEventsTestMixin, ApiTestCase): """Tests for the login end-points of the user API. """ ENABLED_OPENEDX_EVENTS = [] @@ -1055,17 +1044,6 @@ class LoginSessionViewTest(ApiTestCase, OpenEdxEventsTestMixin): EMAIL = "bob@example.com" PASSWORD = "password" - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.url = reverse("user_api_login_session", kwargs={'api_version': 'v1'}) diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index 2f336826b2b5..981a557fe3e8 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -16,7 +16,7 @@ from django.test.client import RequestFactory from django.test.utils import override_settings from django.urls import reverse -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from social_django.models import Partial, UserSocialAuth from testfixtures import LogCapture @@ -74,7 +74,7 @@ @ddt.ddt @skip_unless_lms class RegistrationViewValidationErrorTest( - ThirdPartyAuthTestMixin, UserAPITestCase, RetirementTestCase, OpenEdxEventsTestMixin + OpenEdxEventsTestMixin, ThirdPartyAuthTestMixin, UserAPITestCase, RetirementTestCase ): """ Tests for catching duplicate email and username validation errors within @@ -96,17 +96,6 @@ class RegistrationViewValidationErrorTest( COUNTRY = "US" GOALS = "Learn all the things!" - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): # pylint: disable=arguments-differ super().setUp() self.url = reverse("user_api_registration") @@ -497,7 +486,7 @@ def test_invalid_country_code_error(self): @ddt.ddt @skip_unless_lms class RegistrationViewTestV1( - ThirdPartyAuthTestMixin, UserAPITestCase, OpenEdxEventsTestMixin + OpenEdxEventsTestMixin, ThirdPartyAuthTestMixin, UserAPITestCase ): """Tests for the registration end-points of the User API. """ @@ -563,17 +552,6 @@ class RegistrationViewTestV1( ] link_template = "{link_label}" - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): # pylint: disable=arguments-differ super().setUp() self.url = reverse("user_api_registration") @@ -2077,17 +2055,6 @@ class RegistrationViewTestV2(RegistrationViewTestV1): # pylint: disable=test-inherits-tests - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): # pylint: disable=arguments-differ super(RegistrationViewTestV1, self).setUp() # lint-amnesty, pylint: disable=bad-super-call self.url = reverse("user_api_registration_v2") @@ -2513,7 +2480,7 @@ def test_registration_allowed_when_embargo_disabled(self): @httpretty.activate @ddt.ddt class ThirdPartyRegistrationTestMixin( - ThirdPartyOAuthTestMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin + OpenEdxEventsTestMixin, ThirdPartyOAuthTestMixin, CacheIsolationTestCase ): """ Tests for the User API registration endpoint with 3rd party authentication. @@ -2526,17 +2493,6 @@ class ThirdPartyRegistrationTestMixin( __test__ = False - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() self.url = reverse('user_api_registration') @@ -2731,7 +2687,7 @@ def test_expired_pipeline(self): @skipUnless(settings.FEATURES.get("ENABLE_THIRD_PARTY_AUTH"), "third party auth not enabled") class TestFacebookRegistrationView( - ThirdPartyRegistrationTestMixin, ThirdPartyOAuthTestMixinFacebook, TransactionTestCase, OpenEdxEventsTestMixin + ThirdPartyRegistrationTestMixin, ThirdPartyOAuthTestMixinFacebook, TransactionTestCase ): """Tests the User API registration endpoint with Facebook authentication.""" @@ -2739,17 +2695,6 @@ class TestFacebookRegistrationView( __test__ = True - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def test_social_auth_exception(self): """ According to the do_auth method in social_core.backends.facebook.py, @@ -2763,7 +2708,7 @@ def test_social_auth_exception(self): @skipUnless(settings.FEATURES.get("ENABLE_THIRD_PARTY_AUTH"), "third party auth not enabled") class TestGoogleRegistrationView( - ThirdPartyRegistrationTestMixin, ThirdPartyOAuthTestMixinGoogle, TransactionTestCase, OpenEdxEventsTestMixin + ThirdPartyRegistrationTestMixin, ThirdPartyOAuthTestMixinGoogle, TransactionTestCase ): """Tests the User API registration endpoint with Google authentication.""" @@ -2771,20 +2716,9 @@ class TestGoogleRegistrationView( __test__ = True - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - @ddt.ddt -class RegistrationValidationViewTests(test_utils.ApiTestCase, OpenEdxEventsTestMixin): +class RegistrationValidationViewTests(OpenEdxEventsTestMixin, test_utils.ApiTestCase): """ Tests for validity of user data in registration forms. """ @@ -2794,17 +2728,6 @@ class RegistrationValidationViewTests(test_utils.ApiTestCase, OpenEdxEventsTestM endpoint_name = 'registration_validation' path = reverse(endpoint_name) - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): super().setUp() cache.clear() diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 77a5f9e113a5..9c1eb147b3f8 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -842,7 +842,7 @@ openedx-django-require==3.0.0 # via -r requirements/edx/kernel.in openedx-django-wiki==3.1.1 # via -r requirements/edx/kernel.in -openedx-events==11.1.0 +openedx-events==11.1.1 # via # -r requirements/edx/kernel.in # edx-enterprise diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 657ac94cc455..ff1d59c8fb94 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -1402,7 +1402,7 @@ openedx-django-wiki==3.1.1 # via # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt -openedx-events==11.1.0 +openedx-events==11.1.1 # via # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt diff --git a/requirements/edx/doc.txt b/requirements/edx/doc.txt index 0cc6b952a9b0..0787538eec8a 100644 --- a/requirements/edx/doc.txt +++ b/requirements/edx/doc.txt @@ -1021,7 +1021,7 @@ openedx-django-require==3.0.0 # via -r requirements/edx/base.txt openedx-django-wiki==3.1.1 # via -r requirements/edx/base.txt -openedx-events==11.1.0 +openedx-events==11.1.1 # via # -r requirements/edx/base.txt # edx-enterprise diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 252d9f6ff777..5341bd4bc649 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -1068,7 +1068,7 @@ openedx-django-require==3.0.0 # via -r requirements/edx/base.txt openedx-django-wiki==3.1.1 # via -r requirements/edx/base.txt -openedx-events==11.1.0 +openedx-events==11.1.1 # via # -r requirements/edx/base.txt # edx-enterprise diff --git a/xmodule/modulestore/tests/test_mixed_modulestore.py b/xmodule/modulestore/tests/test_mixed_modulestore.py index 6c0cdc6504d1..aa5f156e0452 100644 --- a/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -33,7 +33,7 @@ XBLOCK_PUBLISHED, XBLOCK_UPDATED, ) -from openedx_events.tests.utils import OpenEdxEventsTestMixin +from openedx_events.testing import OpenEdxEventsTestMixin from web_fragments.fragment import Fragment from xblock.core import XBlockAside from xblock.fields import Scope, ScopeIds, String @@ -69,7 +69,7 @@ log = logging.getLogger(__name__) -class CommonMixedModuleStoreSetup(CourseComparisonTest, OpenEdxEventsTestMixin): +class CommonMixedModuleStoreSetup(OpenEdxEventsTestMixin, CourseComparisonTest): """ Quasi-superclass which tests Location based apps against both split and mongo dbs (Locator and Location-based dbs) @@ -123,16 +123,6 @@ class CommonMixedModuleStoreSetup(CourseComparisonTest, OpenEdxEventsTestMixin): "org.openedx.content_authoring.xblock.published.v1", ] - @classmethod - def setUpClass(cls): - """ - Set up class method for the Test class. - This method starts manually events isolation. Explanation here: - openedx/core/djangoapps/user_authn/views/tests/test_events.py#L44 - """ - super().setUpClass() - cls.start_events_isolation() - def setUp(self): """ Set up the database for testing