Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 2 additions & 18 deletions cms/djangoapps/contentstore/views/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 2 additions & 13 deletions common/djangoapps/student/tests/test_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
"""
Expand All @@ -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. """
Expand Down
22 changes: 3 additions & 19 deletions common/djangoapps/student/tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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()
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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(
Expand Down
15 changes: 2 additions & 13 deletions lms/djangoapps/certificates/tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion lms/djangoapps/certificates/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading
Loading