scoutrule: dedupe skip_unless_lms

This commit is contained in:
J. Cliff Dyer
2017-01-12 14:53:57 -05:00
committed by J. Cliff Dyer
parent 0d2ae5d4af
commit f33832a691
42 changed files with 199 additions and 194 deletions

View File

@@ -1,15 +1,14 @@
#pylint: disable=missing-docstring
import unittest
import ddt
from django.conf import settings
from django.test import TestCase
from openedx.core.djangoapps.api_admin.forms import ApiAccessRequestForm
from openedx.core.djangoapps.api_admin.tests.utils import VALID_DATA
from openedx.core.djangolib.testing.utils import skip_unless_lms
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
@ddt.ddt
class ApiAccessFormTest(TestCase):

View File

@@ -2,21 +2,20 @@
from smtplib import SMTPException
import ddt
from django.conf import settings
from django.db import IntegrityError
from django.test import TestCase
import mock
import unittest
from microsite_configuration.tests.factories import SiteFactory
from openedx.core.djangoapps.api_admin.models import ApiAccessRequest, ApiAccessConfig
from openedx.core.djangoapps.api_admin.models import log as model_log
from openedx.core.djangoapps.api_admin.tests.factories import ApiAccessRequestFactory
from openedx.core.djangolib.testing.utils import skip_unless_lms
from student.tests.factories import UserFactory
@ddt.ddt
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
class ApiAccessRequestTests(TestCase):
def setUp(self):
@@ -79,7 +78,7 @@ class ApiAccessConfigTests(TestCase):
)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
class ApiAccessRequestSignalTests(TestCase):
def setUp(self):
super(ApiAccessRequestSignalTests, self).setUp()

View File

@@ -1,7 +1,6 @@
""" Tests for the api_admin app's views. """
import json
import unittest
import ddt
import httpretty
@@ -16,19 +15,26 @@ from openedx.core.djangoapps.api_admin.tests.factories import (
ApiAccessRequestFactory, ApplicationFactory, CatalogFactory
)
from openedx.core.djangoapps.api_admin.tests.utils import VALID_DATA
from openedx.core.djangolib.testing.utils import skip_unless_lms
from student.tests.factories import UserFactory
Application = get_application_model() # pylint: disable=invalid-name
class ApiAdminTest(TestCase):
"""
Base class to allow API admin access to tests.
"""
def setUp(self):
super(ApiAdminTest, self).setUp()
ApiAccessConfig(enabled=True).save()
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
class ApiRequestViewTest(ApiAdminTest):
"""
Test the API Request View.
"""
def setUp(self):
super(ApiRequestViewTest, self).setUp()
self.url = reverse('api_admin:api-request')
@@ -93,10 +99,13 @@ class ApiRequestViewTest(ApiAdminTest):
self.assertEqual(response.status_code, 404)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
@override_settings(PLATFORM_NAME='edX')
@ddt.ddt
class ApiRequestStatusViewTest(ApiAdminTest):
"""
Tests of the API Status endpoint.
"""
def setUp(self):
super(ApiRequestStatusViewTest, self).setUp()
password = 'abc123'
@@ -198,10 +207,15 @@ class ApiRequestStatusViewTest(ApiAdminTest):
self.assertIn('Enter a valid URL.', response.content)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
class ApiTosViewTest(ApiAdminTest):
"""
Tests of the API terms of service endpoint.
"""
def test_get_api_tos(self):
"""Verify that the terms of service can be read."""
"""
Verify that the terms of service can be read.
"""
url = reverse('api_admin:api-tos')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
@@ -209,6 +223,9 @@ class ApiTosViewTest(ApiAdminTest):
class CatalogTest(ApiAdminTest):
"""
Test the catalog API.
"""
def setUp(self):
super(CatalogTest, self).setUp()
password = 'abc123'
@@ -232,8 +249,11 @@ class CatalogTest(ApiAdminTest):
)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
class CatalogSearchViewTest(CatalogTest):
"""
Test the catalog search endpoint.
"""
def setUp(self):
super(CatalogSearchViewTest, self).setUp()
self.url = reverse('api_admin:catalog-search')
@@ -254,8 +274,11 @@ class CatalogSearchViewTest(CatalogTest):
self.assertRedirects(response, reverse('api_admin:catalog-search'))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
class CatalogListViewTest(CatalogTest):
"""
Test the catalog list endpoint.
"""
def setUp(self):
super(CatalogListViewTest, self).setUp()
self.catalog_user = UserFactory()
@@ -304,8 +327,11 @@ class CatalogListViewTest(CatalogTest):
self.assertEqual(len([r for r in httpretty.httpretty.latest_requests if r.method == 'POST']), 0)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
class CatalogEditViewTest(CatalogTest):
"""
Test edits to the catalog endpoint.
"""
def setUp(self):
super(CatalogEditViewTest, self).setUp()
self.catalog_user = UserFactory()
@@ -353,8 +379,11 @@ class CatalogEditViewTest(CatalogTest):
self.assertEqual(len([r for r in httpretty.httpretty.latest_requests if r.method == 'PATCH']), 0)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@skip_unless_lms
class CatalogPreviewViewTest(CatalogTest):
"""
Test the catalog preview endpoint.
"""
def setUp(self):
super(CatalogPreviewViewTest, self).setUp()
self.url = reverse('api_admin:catalog-preview')