Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
any have taken place.

This functionality is also available as an export view in studio if the giturl
attribute is set and the FEATURE['ENABLE_EXPORT_GIT'] is set.
attribute is set and the ENABLE_EXPORT_GIT setting is enabled.
"""


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
from cms.djangoapps.contentstore.git_export_utils import GitExportError
from cms.djangoapps.contentstore.tests.utils import CourseTestCase

FEATURES_WITH_EXPORT_GIT = settings.FEATURES.copy()
FEATURES_WITH_EXPORT_GIT['ENABLE_EXPORT_GIT'] = True
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex # noqa: UP031


@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
@override_settings(FEATURES=FEATURES_WITH_EXPORT_GIT)
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE, ENABLE_EXPORT_GIT=True)
class TestGitExport(CourseTestCase):
"""
Excercise the git_export django management command with various inputs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from common.djangoapps.student.tests.factories import UserFactory
from common.djangoapps.third_party_auth.models import SAMLConfiguration
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from openedx.core.djangolib.testing.utils import skip_unless_lms

SAML_CONFIGURATIONS = [
{
Expand Down Expand Up @@ -43,7 +43,7 @@
TEST_PASSWORD = 'testpwd'


@skip_unless_thirdpartyauth()
@skip_unless_lms
class SAMLConfigurationTests(APITestCase):
"""
API Tests for SAMLConfiguration objects retrieval.
Expand Down
6 changes: 2 additions & 4 deletions common/djangoapps/third_party_auth/tests/specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import json
import unittest
from contextlib import contextmanager
from unittest import mock

Expand Down Expand Up @@ -31,6 +30,7 @@
from openedx.core.djangoapps.user_authn.views.login import login_user
from openedx.core.djangoapps.user_authn.views.login_form import login_and_registration_form
from openedx.core.djangoapps.user_authn.views.register import RegistrationView
from openedx.core.djangolib.testing.utils import skip_unless_lms


def create_account(request):
Expand Down Expand Up @@ -575,9 +575,7 @@ def complete_url(self):
return reverse("social:complete", kwargs={"backend": self.PROVIDER_BACKEND})


@unittest.skipUnless(
testutil.AUTH_FEATURES_KEY in django_settings.FEATURES, testutil.AUTH_FEATURES_KEY + " not in settings.FEATURES"
)
@skip_unless_lms
@django_utils.override_settings() # For settings reversion on a method-by-method basis.
class IntegrationTest(testutil.TestCase, test.TestCase, HelperMixin):
"""Abstract base class for provider integration tests."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Use the 'Dummy' auth provider for generic integration tests of third_party_auth.
"""
from common.djangoapps.third_party_auth.tests import testutil
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from openedx.core.djangolib.testing.utils import skip_unless_lms

from .base import IntegrationTestMixin


@skip_unless_thirdpartyauth()
@skip_unless_lms
class GenericIntegrationTest(IntegrationTestMixin, testutil.TestCase):
"""
Basic integration tests of third_party_auth using Dummy provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from common.djangoapps.third_party_auth.tests import testutil, utils
from common.test.utils import assert_dict_contains_subset
from openedx.core.djangoapps.user_authn.views.login import login_user
from openedx.core.djangolib.testing.utils import skip_unless_lms

from .base import IntegrationTestMixin

Expand Down Expand Up @@ -160,7 +161,7 @@ def do_provider_login(self, provider_redirect_url):


@ddt.ddt
@utils.skip_unless_thirdpartyauth()
@skip_unless_lms
class TestIndexExceptionTest(SamlIntegrationTestUtilities, IntegrationTestMixin, testutil.SAMLTestCase):
"""
To test SAML error handling when presented with an empty-list attribute value
Expand Down Expand Up @@ -199,7 +200,7 @@ def get_response_data(self):


@ddt.ddt
@utils.skip_unless_thirdpartyauth()
@skip_unless_lms
class TestShibIntegrationTest(SamlIntegrationTestUtilities, IntegrationTestMixin, testutil.SAMLTestCase):
"""
TestShib provider Integration Test, to test SAML functionality
Expand Down Expand Up @@ -404,7 +405,7 @@ def test_login_with_testshib_provider_short_session_length(self):
self._test_return_login(previous_session_timed_out=True)


@utils.skip_unless_thirdpartyauth()
@skip_unless_lms
class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTestMixin, testutil.SAMLTestCase):
"""
Test basic SAML capability using the TestShib details, and then check that we're able
Expand Down
4 changes: 2 additions & 2 deletions common/djangoapps/third_party_auth/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
from common.djangoapps.third_party_auth.admin import OAuth2ProviderConfigAdmin
from common.djangoapps.third_party_auth.models import OAuth2ProviderConfig
from common.djangoapps.third_party_auth.tests import testutil
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from openedx.core.djangolib.testing.utils import skip_unless_lms

TEST_PASSWORD = 'Password1234'


# This is necessary because cms does not implement third party auth
@skip_unless_thirdpartyauth()
@skip_unless_lms
class Oauth2ProviderConfigAdminTest(testutil.TestCase):
"""
Tests for oauth2 provider config admin
Expand Down
4 changes: 2 additions & 2 deletions common/djangoapps/third_party_auth/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from common.djangoapps.third_party_auth.decorators import xframe_allow_whitelisted
from common.djangoapps.third_party_auth.tests.testutil import TestCase
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from openedx.core.djangolib.testing.utils import skip_unless_lms


@xframe_allow_whitelisted
Expand All @@ -17,7 +17,7 @@ def mock_view(_request):
return HttpResponse()


@skip_unless_thirdpartyauth()
@skip_unless_lms
@ddt.ddt
class TestXFrameWhitelistDecorator(TestCase):
""" Test the xframe_allow_whitelisted decorator. """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

from common.djangoapps.third_party_auth.identityserver3 import IdentityServer3
from common.djangoapps.third_party_auth.tests import testutil
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from common.test.utils import assert_dict_contains_subset
from openedx.core.djangolib.testing.utils import skip_unless_lms


@skip_unless_thirdpartyauth()
@skip_unless_lms
@ddt.ddt
class IdentityServer3Test(testutil.TestCase):
"""
Expand Down
6 changes: 3 additions & 3 deletions common/djangoapps/third_party_auth/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from common.djangoapps.third_party_auth.tests.specs.base import IntegrationTestMixin
from common.djangoapps.third_party_auth.tests.specs.test_testshib import SamlIntegrationTestUtilities
from common.djangoapps.third_party_auth.tests.testutil import simulate_running_pipeline
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from openedx.core.djangolib.testing.utils import skip_unless_lms


@skip_unless_thirdpartyauth()
@skip_unless_lms
@ddt.ddt
class ProviderUserStateTestCase(testutil.TestCase):
"""Tests ProviderUserState behavior."""
Expand Down Expand Up @@ -54,7 +54,7 @@ def test_get_idp_logout_url_from_running_pipeline(self, idp_type, backend_name):
assert idp_config['logout_url'] == logout_url


@skip_unless_thirdpartyauth()
@skip_unless_lms
@ddt.ddt
class PipelineOverridesTest(SamlIntegrationTestUtilities, IntegrationTestMixin, testutil.SAMLTestCase):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
from common.djangoapps.student.tests.factories import UserFactory
from common.djangoapps.third_party_auth import pipeline, provider
from common.djangoapps.third_party_auth.tests import testutil
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from lms.djangoapps.verify_student.models import SSOVerification
from openedx.core.djangolib.testing.utils import skip_unless_lms

# Get Django User model by reference from python-social-auth. Not a type
# constant, pylint.
User = social_models.DjangoStorage.user.user_model() # pylint: disable=invalid-name


@skip_unless_thirdpartyauth()
@skip_unless_lms
class TestCase(testutil.TestCase, test.TestCase):
"""Base test case."""

Expand Down
4 changes: 2 additions & 2 deletions common/djangoapps/third_party_auth/tests/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

from common.djangoapps.third_party_auth import provider
from common.djangoapps.third_party_auth.tests import testutil
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from openedx.core.djangoapps.site_configuration.tests.test_util import (
with_site_configuration,
with_site_configuration_context,
)
from openedx.core.djangolib.testing.utils import skip_unless_lms

SITE_DOMAIN_A = 'professionalx.example.com'
SITE_DOMAIN_B = 'somethingelse.example.com'


@skip_unless_thirdpartyauth()
@skip_unless_lms
class RegistryTest(testutil.TestCase):
"""Tests registry discovery and operation."""

Expand Down
3 changes: 1 addition & 2 deletions common/djangoapps/third_party_auth/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django.test import TestCase, override_settings

from common.djangoapps.third_party_auth import provider
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
from openedx.core.djangolib.testing.utils import skip_unless_lms


Expand All @@ -20,7 +19,7 @@ def test_fields_stored_in_session_defined(self):
"""Verify FIELDS_STORED_IN_SESSION is defined with expected values."""
assert settings.FIELDS_STORED_IN_SESSION == ['auth_entry', 'next']

@skip_unless_thirdpartyauth()
@skip_unless_lms
def test_no_providers_enabled_by_default(self):
"""Providers are only enabled via ConfigurationModels in the database."""
assert provider.Registry.enabled() == []
Expand Down
12 changes: 6 additions & 6 deletions common/djangoapps/third_party_auth/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""


import unittest
from unittest.mock import patch

import ddt
Expand All @@ -22,13 +21,14 @@
# Define some XML namespaces:
from common.djangoapps.third_party_auth.utils import SAML_XML_NS
from common.djangoapps.third_party_auth.views import inactive_user_view
from openedx.core.djangolib.testing.utils import skip_unless_lms

from .testutil import AUTH_FEATURE_ENABLED, AUTH_FEATURES_KEY, SAMLTestCase
from .testutil import SAMLTestCase

XMLDSIG_XML_NS = 'http://www.w3.org/2000/09/xmldsig#'


@unittest.skipUnless(AUTH_FEATURE_ENABLED, AUTH_FEATURES_KEY + ' not enabled')
@skip_unless_lms
@ddt.ddt
class SAMLMetadataTest(SAMLTestCase):
"""
Expand Down Expand Up @@ -146,7 +146,7 @@ def check_metadata_contacts(self, xml, tech_name, tech_email, support_name, supp
assert support_email_node.text == support_email


@unittest.skipUnless(AUTH_FEATURE_ENABLED, AUTH_FEATURES_KEY + ' not enabled')
@skip_unless_lms
class SAMLAuthTest(SAMLTestCase):
"""
Test the SAML auth views
Expand All @@ -166,7 +166,7 @@ def test_login_disabled(self):
assert response.status_code == 404


@unittest.skipUnless(AUTH_FEATURE_ENABLED, AUTH_FEATURES_KEY + ' not enabled')
@skip_unless_lms
class IdPRedirectViewTest(SAMLTestCase):
"""
Test IdPRedirectView.
Expand Down Expand Up @@ -206,7 +206,7 @@ def get_idp_redirect_url(provider_slug, next_destination=None):
)


@unittest.skipUnless(AUTH_FEATURE_ENABLED, AUTH_FEATURES_KEY + ' not enabled')
@skip_unless_lms
class InactiveUserViewTests(TestCase):
"""Test inactive user view """
@patch('common.djangoapps.third_party_auth.views.redirect')
Expand Down
4 changes: 0 additions & 4 deletions common/djangoapps/third_party_auth/tests/testutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from unittest import mock

import django.test
from django.conf import settings
from django.contrib.auth.models import User # pylint: disable=imported-auth-user
from django.contrib.sites.models import Site
from mako.template import Template
Expand All @@ -26,9 +25,6 @@
from openedx.core.djangolib.testing.utils import CacheIsolationMixin
from openedx.core.storage import OverwriteStorage

AUTH_FEATURES_KEY = 'ENABLE_THIRD_PARTY_AUTH'
AUTH_FEATURE_ENABLED = hasattr(settings, AUTH_FEATURES_KEY)


def patch_mako_templates():
""" Patch mako so the django test client can access template context """
Expand Down
12 changes: 1 addition & 11 deletions common/djangoapps/third_party_auth/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import json
from base64 import b64encode
from unittest import skip

import httpretty
from oauth2_provider.models import Application
Expand All @@ -14,7 +13,7 @@

from common.djangoapps.student.tests.factories import UserFactory

from .testutil import AUTH_FEATURE_ENABLED, AUTH_FEATURES_KEY, ThirdPartyAuthTestMixin
from .testutil import ThirdPartyAuthTestMixin


@httpretty.activate
Expand Down Expand Up @@ -144,12 +143,3 @@ def prepare_saml_response_from_xml(xml, relay_state='testshib'):
relay_state=OneLogin_Saml2_Utils.escape_url(relay_state),
saml_response=OneLogin_Saml2_Utils.escape_url(b64encoded_xml)
)


def skip_unless_thirdpartyauth():
"""
Wraps unittest.skip in consistent logic to skip certain third_party_auth tests in CMS.
"""
if AUTH_FEATURE_ENABLED:
return lambda func: func
return skip("%s not enabled" % AUTH_FEATURES_KEY) # noqa: UP031
6 changes: 1 addition & 5 deletions lms/djangoapps/certificates/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import ddt
import pytest
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase
Expand Down Expand Up @@ -46,9 +45,6 @@
ENROLLMENT_METHOD = 'common.djangoapps.student.models.course_enrollment.CourseEnrollment.enrollment_mode_for_user'
PROFILE_METHOD = 'common.djangoapps.student.models_api.get_name'

FEATURES_INVALID_FILE_PATH = settings.FEATURES.copy()
FEATURES_INVALID_FILE_PATH['CERTS_HTML_VIEW_CONFIG_PATH'] = 'invalid/path/to/config.json'

TEST_DIR = path(__file__).dirname()
TEST_DATA_DIR = 'common/test/data/'
PLATFORM_ROOT = TEST_DIR.parent.parent.parent.parent
Expand Down Expand Up @@ -175,7 +171,7 @@ def test_get_not_enabled_returns_blank(self):
self.config.save()
assert len(self.config.get_config()) == 0

@override_settings(FEATURES=FEATURES_INVALID_FILE_PATH)
@override_settings(CERTS_HTML_VIEW_CONFIG_PATH='invalid/path/to/config.json')
def test_get_no_database_no_file(self):
"""
Tests get configuration that is not enabled.
Expand Down
10 changes: 5 additions & 5 deletions lms/djangoapps/courseware/tests/test_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,11 @@ def test_initialize_default_without_external_link(self):
assert not self.has_tab(self.course.tabs, 'external_discussion')
assert self.has_tab(self.course.tabs, 'discussion')

@override_settings(ENABLE_DISCUSSION_SERVICE=True)
@patch.dict("django.conf.settings.FEATURES", {
"ENABLE_TEXTBOOK": True,
"ENABLE_EDXNOTES": True,
})
@override_settings(
ENABLE_DISCUSSION_SERVICE=True,
ENABLE_TEXTBOOK=True,
ENABLE_EDXNOTES=True,
)
def test_iterate_displayable(self):
self.course.hide_progress_tab = False

Expand Down
Loading
Loading