refactor(test): use @skip_unless_lms uniformly
This commit is contained in:
committed by
Ned Batchelder
parent
71e2aa7018
commit
12765a7a59
@@ -1,18 +1,18 @@
|
||||
# pylint: disable=missing-module-docstring
|
||||
import unittest
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import ddt
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import CommandError
|
||||
from django.test import TestCase
|
||||
from openedx.core.djangoapps.api_admin.models import ApiAccessConfig, ApiAccessRequest
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Tests only valid in lms')
|
||||
@skip_unless_lms
|
||||
@ddt.ddt
|
||||
class TestCreateApiAccessRequest(TestCase):
|
||||
""" Test create_api_access_request command """
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
|
||||
import json
|
||||
import unittest
|
||||
|
||||
from django.conf import settings
|
||||
from django.urls import NoReverseMatch, reverse
|
||||
@@ -11,12 +10,14 @@ from django.test import TestCase
|
||||
import ddt
|
||||
from config_models.models import cache
|
||||
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
|
||||
# cors_csrf is not in CMS' INSTALLED_APPS so these imports will error during test collection
|
||||
if settings.ROOT_URLCONF == 'lms.urls':
|
||||
from ..models import XDomainProxyConfiguration
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
@ddt.ddt
|
||||
class XDomainProxyTest(TestCase):
|
||||
"""Tests for the xdomain proxy end-point. """
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"""
|
||||
Tests for courseware API
|
||||
"""
|
||||
import unittest
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from urllib.parse import urlencode
|
||||
from typing import Optional
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
from completion.test_utils import CompletionWaffleTestMixin, submit_completions_for_testing
|
||||
from django.conf import settings
|
||||
@@ -43,6 +43,7 @@ from common.djangoapps.student.models import (
|
||||
from common.djangoapps.student.roles import CourseInstructorRole
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentCelebrationFactory, UserFactory
|
||||
from openedx.core.djangoapps.agreements.api import create_integrity_signature
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
|
||||
|
||||
User = get_user_model()
|
||||
@@ -50,7 +51,7 @@ User = get_user_model()
|
||||
_NEXT_WEEK = datetime.now() + timedelta(days=7)
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class BaseCoursewareTests(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Base class for courseware API tests
|
||||
@@ -100,7 +101,7 @@ class BaseCoursewareTests(SharedModuleStoreTestCase):
|
||||
@ddt.ddt
|
||||
@override_waffle_flag(COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES, active=True)
|
||||
@override_waffle_flag(COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES_STREAK_CELEBRATION, active=True)
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class CourseApiTestViews(BaseCoursewareTests, MasqueradeMixin):
|
||||
"""
|
||||
Tests for the courseware REST API
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
""" Test the change_enrollment command line script."""
|
||||
|
||||
|
||||
import unittest
|
||||
from uuid import uuid4
|
||||
|
||||
import ddt
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import CommandError
|
||||
|
||||
from openedx.core.djangoapps.enrollments.api import get_enrollment
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from openedx.core.djangoapps.enrollments.api import get_enrollment
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class EnrollManagementCommandTest(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Test the enroll_user_in_course management command
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
Tests for student enrollment.
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import ddt
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
@@ -17,12 +14,12 @@ from openedx.core.djangoapps.enrollments.errors import (
|
||||
CourseModeNotFoundError, EnrollmentApiLoadError, EnrollmentNotFoundError,
|
||||
)
|
||||
from openedx.core.djangoapps.enrollments.tests import fake_data_api
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@override_settings(ENROLLMENT_DATA_API="openedx.core.djangoapps.enrollments.tests.fake_data_api")
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class EnrollmentTest(CacheIsolationTestCase):
|
||||
"""
|
||||
Test student enrollment, especially with different course modes.
|
||||
|
||||
@@ -3,14 +3,11 @@ Test the Data Aggregation Layer for Course Enrollments.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import datetime
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import ddt
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
from pytz import UTC
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
@@ -23,6 +20,7 @@ from openedx.core.djangoapps.enrollments.errors import (
|
||||
UserNotFoundError
|
||||
)
|
||||
from openedx.core.djangoapps.enrollments.serializers import CourseEnrollmentSerializer
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from openedx.core.lib.exceptions import CourseNotFoundError
|
||||
from common.djangoapps.student.models import AlreadyEnrolledError, CourseEnrollment, CourseFullError, EnrollmentClosedError # lint-amnesty, pylint: disable=line-too-long
|
||||
from common.djangoapps.student.tests.factories import CourseAccessRoleFactory, UserFactory, CourseEnrollmentFactory
|
||||
@@ -31,7 +29,7 @@ from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, p
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class EnrollmentDataTest(ModuleStoreTestCase):
|
||||
"""
|
||||
Test course enrollment data aggregation.
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
Tests for user enrollment.
|
||||
"""
|
||||
|
||||
|
||||
import datetime
|
||||
import itertools
|
||||
import json
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from urllib.parse import quote
|
||||
|
||||
@@ -39,6 +37,7 @@ from openedx.core.djangoapps.enrollments.errors import CourseEnrollmentError
|
||||
from openedx.core.djangoapps.enrollments.views import EnrollmentUserThrottle
|
||||
from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_for_user
|
||||
from openedx.core.djangoapps.user_api.models import RetirementState, UserOrgTag, UserRetirementStatus
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from openedx.core.lib.django_test_client_utils import get_absolute_url
|
||||
from openedx.features.enterprise_support.tests import FAKE_ENTERPRISE_CUSTOMER
|
||||
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
|
||||
@@ -155,7 +154,7 @@ class EnrollmentTestMixin:
|
||||
|
||||
@override_settings(EDX_API_KEY="i am a key")
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, EnterpriseServiceMockMixin):
|
||||
"""
|
||||
Test user enrollment, especially with different course modes.
|
||||
@@ -1214,7 +1213,7 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente
|
||||
assert enrollment.attributes.get(namespace='order', name='order_number').value == order_number
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestCase):
|
||||
"""Test that enrollment is blocked from embargoed countries. """
|
||||
|
||||
@@ -1346,7 +1345,7 @@ def cross_domain_config(func):
|
||||
)
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class EnrollmentCrossDomainTest(ModuleStoreTestCase):
|
||||
"""Test cross-domain calls to the enrollment end-points. """
|
||||
|
||||
@@ -1405,7 +1404,7 @@ class EnrollmentCrossDomainTest(ModuleStoreTestCase):
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class UnenrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase):
|
||||
"""
|
||||
Tests unenrollment functionality. The API being tested is intended to
|
||||
@@ -1558,7 +1557,7 @@ class UnenrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase):
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class UserRoleTest(ModuleStoreTestCase):
|
||||
"""
|
||||
Tests the API call to list user roles.
|
||||
@@ -1666,7 +1665,7 @@ class UserRoleTest(ModuleStoreTestCase):
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class CourseEnrollmentsApiListTest(APITestCase, ModuleStoreTestCase):
|
||||
"""
|
||||
Test the course enrollments list API.
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
Tests the ``edx_clear_expired_tokens`` management command.
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -19,6 +17,7 @@ from oauth2_provider.models import AccessToken, RefreshToken
|
||||
from testfixtures import LogCapture
|
||||
|
||||
from openedx.core.djangoapps.oauth_dispatch.tests import factories
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
|
||||
LOGGER_NAME = 'openedx.core.djangoapps.oauth_dispatch.management.commands.edx_clear_expired_tokens'
|
||||
@@ -37,7 +36,7 @@ def counter(fn):
|
||||
return _counted
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class EdxClearExpiredTokensTests(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
|
||||
# patching REFRESH_TOKEN_EXPIRE_SECONDS because override_settings not working.
|
||||
|
||||
@@ -4,15 +4,14 @@ Test of custom django-oauth-toolkit behavior
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
|
||||
import datetime
|
||||
import unittest
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import RequestFactory, TestCase
|
||||
from django.utils import timezone
|
||||
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
|
||||
# oauth_dispatch is not in CMS' INSTALLED_APPS so these imports will error during test collection
|
||||
if settings.ROOT_URLCONF == 'lms.urls':
|
||||
@@ -24,7 +23,7 @@ if settings.ROOT_URLCONF == 'lms.urls':
|
||||
from .constants import DUMMY_REDIRECT_URL
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class AuthenticateTestCase(TestCase):
|
||||
"""
|
||||
Test that users can authenticate with either username or email
|
||||
@@ -48,7 +47,7 @@ class AuthenticateTestCase(TestCase):
|
||||
assert self.user == user
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class CustomValidationTestCase(TestCase):
|
||||
"""
|
||||
Test custom user validation works.
|
||||
@@ -77,7 +76,7 @@ class CustomValidationTestCase(TestCase):
|
||||
assert self.validator.validate_user('darkhelmet', '12345', client=None, request=request)
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
class CustomAuthorizationViewTestCase(TestCase):
|
||||
"""
|
||||
Test custom authorization view works.
|
||||
|
||||
@@ -2,16 +2,13 @@
|
||||
Test cases to cover account retirement views
|
||||
"""
|
||||
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import pytz
|
||||
from consent.models import DataSharingConsent
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core import mail
|
||||
@@ -74,6 +71,7 @@ from common.djangoapps.student.tests.factories import (
|
||||
SuperuserFactory,
|
||||
UserFactory
|
||||
)
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
@@ -98,7 +96,7 @@ def build_jwt_headers(user):
|
||||
return headers
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestAccountDeactivation(TestCase):
|
||||
"""
|
||||
Tests the account deactivation endpoint.
|
||||
@@ -170,7 +168,7 @@ class TestAccountDeactivation(TestCase):
|
||||
)
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestDeactivateLogout(RetirementTestCase):
|
||||
"""
|
||||
Tests the account deactivation/logout endpoint.
|
||||
@@ -266,7 +264,7 @@ class TestDeactivateLogout(RetirementTestCase):
|
||||
assert response.status_code == status.HTTP_403_FORBIDDEN
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestPartnerReportingCleanup(ModuleStoreTestCase):
|
||||
"""
|
||||
Tests the partner reporting cleanup endpoint.
|
||||
@@ -378,7 +376,7 @@ class TestPartnerReportingCleanup(ModuleStoreTestCase):
|
||||
self.assert_status_and_count(statuses, len(statuses))
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestPartnerReportingPut(RetirementTestCase, ModuleStoreTestCase):
|
||||
"""
|
||||
Tests the partner reporting list endpoint
|
||||
@@ -474,7 +472,7 @@ class TestPartnerReportingPut(RetirementTestCase, ModuleStoreTestCase):
|
||||
assert UserRetirementPartnerReportingStatus.objects.filter(user=retirement.user).exists()
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestPartnerReportingList(ModuleStoreTestCase):
|
||||
"""
|
||||
Tests the partner reporting list endpoint
|
||||
@@ -687,7 +685,7 @@ class TestPartnerReportingList(ModuleStoreTestCase):
|
||||
self.assert_status_and_user_list([])
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestAccountRetirementList(RetirementTestCase):
|
||||
"""
|
||||
Tests the account retirement endpoint.
|
||||
@@ -847,7 +845,7 @@ class TestAccountRetirementList(RetirementTestCase):
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestAccountRetirementsByStatusAndDate(RetirementTestCase):
|
||||
"""
|
||||
Tests the retirements_by_status_and_date endpoint
|
||||
@@ -995,7 +993,7 @@ class TestAccountRetirementsByStatusAndDate(RetirementTestCase):
|
||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestAccountRetirementRetrieve(RetirementTestCase):
|
||||
"""
|
||||
Tests the account retirement retrieval endpoint.
|
||||
@@ -1066,7 +1064,7 @@ class TestAccountRetirementRetrieve(RetirementTestCase):
|
||||
self.assert_status_and_user_data(values, username_to_find=original_username)
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestAccountRetirementCleanup(RetirementTestCase):
|
||||
"""
|
||||
Tests the account retirement cleanup endpoint.
|
||||
@@ -1141,7 +1139,7 @@ class TestAccountRetirementCleanup(RetirementTestCase):
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestAccountRetirementUpdate(RetirementTestCase):
|
||||
"""
|
||||
Tests the account retirement endpoint.
|
||||
@@ -1281,7 +1279,7 @@ class TestAccountRetirementUpdate(RetirementTestCase):
|
||||
self.update_and_assert_status(data, expected_response_code)
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestAccountRetirementPost(RetirementTestCase):
|
||||
"""
|
||||
Tests the account retirement endpoint.
|
||||
@@ -1559,7 +1557,7 @@ class TestAccountRetirementPost(RetirementTestCase):
|
||||
assert '' == self.entitlement_support_detail.comments
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Account APIs are only supported in LMS')
|
||||
@skip_unless_lms
|
||||
class TestLMSAccountRetirementPost(RetirementTestCase, ModuleStoreTestCase):
|
||||
"""
|
||||
Tests the LMS account retirement (GDPR P2) endpoint.
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
Tests for logout
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
import urllib
|
||||
from unittest import mock
|
||||
import ddt
|
||||
@@ -14,10 +12,11 @@ from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
|
||||
from openedx.core.djangoapps.oauth_dispatch.tests.factories import ApplicationFactory
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
@ddt.ddt
|
||||
class LogoutTests(TestCase):
|
||||
""" Tests for the logout functionality. """
|
||||
|
||||
@@ -5,9 +5,9 @@ Test the various password reset flows
|
||||
import json
|
||||
import re
|
||||
import unicodedata
|
||||
import unittest
|
||||
from datetime import datetime, timedelta
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import ddt
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, make_password
|
||||
@@ -54,10 +54,7 @@ def process_request(request):
|
||||
request.session.save()
|
||||
|
||||
|
||||
@unittest.skipUnless(
|
||||
settings.ROOT_URLCONF == "lms.urls",
|
||||
"reset password tests should only run in LMS"
|
||||
)
|
||||
@skip_unless_lms
|
||||
@ddt.ddt
|
||||
class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
"""
|
||||
@@ -300,7 +297,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
response = password_reset(reset_request)
|
||||
assert response.status_code == status
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
|
||||
@skip_unless_lms
|
||||
@ddt.data(('plain_text', "You're receiving this e-mail because you requested a password reset"),
|
||||
('html', "You're receiving this e-mail because you requested a password reset"))
|
||||
@ddt.unpack
|
||||
@@ -347,7 +344,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
assert 'password_reset_confirm/' in body
|
||||
re.search(r'password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/', body).groupdict()
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
|
||||
@skip_unless_lms
|
||||
@ddt.data((False, 'http://'), (True, 'https://'))
|
||||
@ddt.unpack
|
||||
def test_reset_password_email_https(self, is_secure, protocol):
|
||||
@@ -372,7 +369,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
)
|
||||
|
||||
@override_settings(FEATURES=ENABLE_AUTHN_MICROFRONTEND)
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
|
||||
@skip_unless_lms
|
||||
@ddt.data(('Crazy Awesome Site', 'Crazy Awesome Site'), ('edX', 'edX'))
|
||||
@ddt.unpack
|
||||
def test_reset_password_email_site(self, site_name, platform_name):
|
||||
@@ -404,7 +401,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
SETTING_CHANGE_INITIATED, user_id=self.user.id, setting='password', old=None, new=None
|
||||
)
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
|
||||
@skip_unless_lms
|
||||
@patch("openedx.core.djangoapps.site_configuration.helpers.get_value", fake_get_value)
|
||||
@ddt.data('plain_text', 'html')
|
||||
def test_reset_password_email_configuration_override(self, body_type):
|
||||
@@ -628,7 +625,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
self.user = User.objects.get(pk=self.user.pk)
|
||||
assert self.user.is_active
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
|
||||
@skip_unless_lms
|
||||
@ddt.data('Crazy Awesome Site', 'edX')
|
||||
def test_reset_password_email_subject(self, platform_name):
|
||||
"""
|
||||
@@ -835,10 +832,7 @@ class PasswordResetTokenValidateViewTest(UserAPITestCase):
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(
|
||||
settings.ROOT_URLCONF == "lms.urls",
|
||||
"reset password tests should only run in LMS"
|
||||
)
|
||||
@skip_unless_lms
|
||||
class ResetPasswordAPITests(EventTestMixin, CacheIsolationTestCase):
|
||||
"""Tests of the logistration API's password reset endpoint. """
|
||||
request_factory = RequestFactory()
|
||||
|
||||
@@ -2,19 +2,18 @@
|
||||
Tests for the gating API
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
from completion.models import BlockCompletion
|
||||
from ddt import data, ddt, unpack
|
||||
from django.conf import settings
|
||||
from milestones import api as milestones_api
|
||||
from milestones.tests.utils import MilestonesTestCaseMixin
|
||||
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory
|
||||
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from lms.djangoapps.gating import api as lms_gating_api
|
||||
from lms.djangoapps.grades.constants import GradeOverrideFeatureEnum
|
||||
from lms.djangoapps.grades.models import PersistentSubsectionGrade, PersistentSubsectionGradeOverride
|
||||
@@ -237,7 +236,7 @@ class TestGatingApi(ModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
(0, 1, 0),
|
||||
)
|
||||
@unpack
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
def test_get_subsection_completion_percentage(self, user_problem_completion, user_html_completion,
|
||||
expected_completion_percentage):
|
||||
"""
|
||||
@@ -276,7 +275,7 @@ class TestGatingApi(ModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
('openassessment', 0, 0),
|
||||
)
|
||||
@unpack
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
def test_get_subsection_completion_percentage_single_component(
|
||||
self,
|
||||
component_type,
|
||||
@@ -306,7 +305,7 @@ class TestGatingApi(ModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
completion_percentage = gating_api.get_subsection_completion_percentage(self.seq1.location, student)
|
||||
assert completion_percentage == expected_completion_percentage
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
def test_compute_is_prereq_met(self):
|
||||
"""
|
||||
Test if prereq has been met and force recompute
|
||||
@@ -353,7 +352,7 @@ class TestGatingGradesIntegration(GradeTestBase):
|
||||
"""
|
||||
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
def test_get_subsection_grade_percentage(self):
|
||||
user = self.request.user
|
||||
subsection_key = self.sequence.location
|
||||
@@ -368,7 +367,7 @@ class TestGatingGradesIntegration(GradeTestBase):
|
||||
grade_percentage = gating_api.get_subsection_grade_percentage(subsection_key, user)
|
||||
assert 100.0 == grade_percentage
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
@skip_unless_lms
|
||||
def test_get_subsection_grade_percentage_with_override(self):
|
||||
user = self.request.user
|
||||
subsection_key = self.sequence.location
|
||||
|
||||
Reference in New Issue
Block a user