diff --git a/openedx/core/djangoapps/bookmarks/tests/test_api.py b/openedx/core/djangoapps/bookmarks/tests/test_api.py index 556bc155ea..f3570ff712 100644 --- a/openedx/core/djangoapps/bookmarks/tests/test_api.py +++ b/openedx/core/djangoapps/bookmarks/tests/test_api.py @@ -3,7 +3,6 @@ Tests for bookmarks api. """ import ddt from mock import patch -from nose.plugins.attrib import attr from django.conf import settings from django.core.exceptions import ObjectDoesNotExist @@ -36,13 +35,14 @@ class BookmarkApiEventTestMixin(object): self.assertFalse(mock_tracker.called) # pylint: disable=maybe-no-member -@attr(shard=9) @ddt.ddt @skip_unless_lms class BookmarksAPITests(BookmarkApiEventTestMixin, BookmarksTestsBase): """ These tests cover the parts of the API methods. """ + shard = 9 + def test_get_bookmark(self): """ Verifies that get_bookmark returns data as expected. diff --git a/openedx/core/djangoapps/bookmarks/tests/test_models.py b/openedx/core/djangoapps/bookmarks/tests/test_models.py index b24af44527..132a6f60f5 100644 --- a/openedx/core/djangoapps/bookmarks/tests/test_models.py +++ b/openedx/core/djangoapps/bookmarks/tests/test_models.py @@ -8,7 +8,6 @@ import ddt import mock import pytz from freezegun import freeze_time -from nose.plugins.attrib import attr from opaque_keys.edx.keys import UsageKey from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator @@ -224,13 +223,14 @@ class BookmarksTestsBase(ModuleStoreTestCase): self.assertEqual(bookmark_data['path'], bookmark.path) -@attr(shard=9) @ddt.ddt @skip_unless_lms class BookmarkModelTests(BookmarksTestsBase): """ Test the Bookmark model. """ + shard = 9 + def setUp(self): super(BookmarkModelTests, self).setUp() @@ -410,13 +410,12 @@ class BookmarkModelTests(BookmarksTestsBase): self.assertEqual(bookmark.path, []) -@attr(shard=9) @ddt.ddt class XBlockCacheModelTest(ModuleStoreTestCase): """ Test the XBlockCache model. """ - + shard = 9 COURSE_KEY = CourseLocator(org='test', course='test', run='test') CHAPTER1_USAGE_KEY = BlockUsageLocator(COURSE_KEY, block_type='chapter', block_id='chapter1') SECTION1_USAGE_KEY = BlockUsageLocator(COURSE_KEY, block_type='section', block_id='section1') diff --git a/openedx/core/djangoapps/bookmarks/tests/test_services.py b/openedx/core/djangoapps/bookmarks/tests/test_services.py index 33a6ff942a..87c65a9dfc 100644 --- a/openedx/core/djangoapps/bookmarks/tests/test_services.py +++ b/openedx/core/djangoapps/bookmarks/tests/test_services.py @@ -2,7 +2,6 @@ Tests for bookmark services. """ -from nose.plugins.attrib import attr from opaque_keys.edx.keys import UsageKey from openedx.core.djangolib.testing.utils import skip_unless_lms @@ -10,12 +9,12 @@ from ..services import BookmarksService from .test_models import BookmarksTestsBase -@attr(shard=9) @skip_unless_lms class BookmarksServiceTests(BookmarksTestsBase): """ Tests the Bookmarks service. """ + shard = 9 def setUp(self): super(BookmarksServiceTests, self).setUp() diff --git a/openedx/core/djangoapps/bookmarks/tests/test_tasks.py b/openedx/core/djangoapps/bookmarks/tests/test_tasks.py index 88920c956f..c2559bc088 100644 --- a/openedx/core/djangoapps/bookmarks/tests/test_tasks.py +++ b/openedx/core/djangoapps/bookmarks/tests/test_tasks.py @@ -2,7 +2,6 @@ Tests for tasks. """ import ddt -from nose.plugins.attrib import attr from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.factories import check_mongo_calls, ItemFactory @@ -11,12 +10,12 @@ from ..tasks import _calculate_course_xblocks_data, _update_xblocks_cache from .test_models import BookmarksTestsBase -@attr(shard=9) @ddt.ddt class XBlockCacheTaskTests(BookmarksTestsBase): """ Test the XBlockCache model. """ + shard = 9 def setUp(self): super(XBlockCacheTaskTests, self).setUp() diff --git a/openedx/core/djangoapps/bookmarks/tests/test_views.py b/openedx/core/djangoapps/bookmarks/tests/test_views.py index e6ab3dc3b5..978211af8e 100644 --- a/openedx/core/djangoapps/bookmarks/tests/test_views.py +++ b/openedx/core/djangoapps/bookmarks/tests/test_views.py @@ -8,7 +8,6 @@ import ddt from django.conf import settings from django.urls import reverse from mock import patch -from nose.plugins.attrib import attr from rest_framework.test import APIClient from openedx.core.djangolib.testing.utils import skip_unless_lms @@ -61,7 +60,6 @@ class BookmarksViewsTestsBase(BookmarksTestsBase, BookmarkApiEventTestMixin): return response -@attr(shard=9) @ddt.ddt @skip_unless_lms class BookmarksListViewTests(BookmarksViewsTestsBase): @@ -70,6 +68,8 @@ class BookmarksListViewTests(BookmarksViewsTestsBase): GET /api/bookmarks/v1/bookmarks/?course_id={course_id1} POST /api/bookmarks/v1/bookmarks """ + shard = 9 + @ddt.data( (1, False), (10, False), @@ -366,13 +366,14 @@ class BookmarksListViewTests(BookmarksViewsTestsBase): ) -@attr(shard=9) @ddt.ddt @skip_unless_lms class BookmarksDetailViewTests(BookmarksViewsTestsBase): """ This contains the tests for GET & DELETE methods of bookmark.views.BookmarksDetailView class """ + shard = 9 + @ddt.data( ('', False), ('fields=path,display_name', True) diff --git a/openedx/core/djangoapps/ccxcon/tests/test_api.py b/openedx/core/djangoapps/ccxcon/tests/test_api.py index e62f99c2e7..9544387187 100644 --- a/openedx/core/djangoapps/ccxcon/tests/test_api.py +++ b/openedx/core/djangoapps/ccxcon/tests/test_api.py @@ -6,7 +6,6 @@ import datetime import mock import pytz import urlparse -from nose.plugins.attrib import attr from opaque_keys.edx.keys import CourseKey from student.tests.factories import AdminFactory @@ -38,12 +37,12 @@ def fetch_token_mock(*args, **kwargs): # pylint: disable=unused-argument return -@attr(shard=1) class APIsTestCase(SharedModuleStoreTestCase): """ Unit tests for the API module functions """ MODULESTORE = TEST_DATA_SPLIT_MODULESTORE + shard = 1 @classmethod def setUpClass(cls): diff --git a/openedx/core/djangoapps/ccxcon/tests/test_signals.py b/openedx/core/djangoapps/ccxcon/tests/test_signals.py index 9eb2ff87e7..cc6084e0f1 100644 --- a/openedx/core/djangoapps/ccxcon/tests/test_signals.py +++ b/openedx/core/djangoapps/ccxcon/tests/test_signals.py @@ -3,20 +3,19 @@ Test for contentstore signals receiver """ import mock -from nose.plugins.attrib import attr from django.test import TestCase from opaque_keys.edx.keys import CourseKey from xmodule.modulestore.django import modulestore, SignalHandler -@attr(shard=2) class CCXConSignalTestCase(TestCase): """ The only tests currently implemented are for verifying that the call for the ccxcon update are performed correctly by the course_published signal handler """ + shard = 2 @mock.patch('openedx.core.djangoapps.ccxcon.tasks.update_ccxcon.delay') def test_course_published_ccxcon_call(self, mock_upc): diff --git a/openedx/core/djangoapps/ccxcon/tests/test_tasks.py b/openedx/core/djangoapps/ccxcon/tests/test_tasks.py index 12cafa99cd..9dd99e5719 100644 --- a/openedx/core/djangoapps/ccxcon/tests/test_tasks.py +++ b/openedx/core/djangoapps/ccxcon/tests/test_tasks.py @@ -3,7 +3,6 @@ Tests for the CCXCon celery tasks """ import mock -from nose.plugins.attrib import attr from django.test import TestCase @@ -11,11 +10,11 @@ from opaque_keys.edx.keys import CourseKey from openedx.core.djangoapps.ccxcon import api, tasks -@attr(shard=2) class CCXConTaskTestCase(TestCase): """ Tests for CCXCon tasks. """ + shard = 2 @mock.patch('openedx.core.djangoapps.ccxcon.api.course_info_to_ccxcon') def test_update_ccxcon_task_ok(self, mock_citc): diff --git a/openedx/core/djangoapps/content/block_structure/tests/test_block_structure.py b/openedx/core/djangoapps/content/block_structure/tests/test_block_structure.py index cae3756ca7..19039b479f 100644 --- a/openedx/core/djangoapps/content/block_structure/tests/test_block_structure.py +++ b/openedx/core/djangoapps/content/block_structure/tests/test_block_structure.py @@ -5,11 +5,11 @@ from datetime import datetime # pylint: disable=protected-access from collections import namedtuple from copy import deepcopy -import ddt import itertools -from nose.plugins.attrib import attr from unittest import TestCase +import ddt + from openedx.core.lib.graph_traversals import traverse_post_order from ..block_structure import BlockStructure, BlockStructureModulestoreData @@ -17,12 +17,13 @@ from ..exceptions import TransformerException from .helpers import MockXBlock, MockTransformer, ChildrenMapTestMixin -@attr(shard=2) @ddt.ddt class TestBlockStructure(TestCase, ChildrenMapTestMixin): """ Tests for BlockStructure """ + shard = 2 + @ddt.data( [], ChildrenMapTestMixin.SIMPLE_CHILDREN_MAP, @@ -46,12 +47,13 @@ class TestBlockStructure(TestCase, ChildrenMapTestMixin): self.assertNotIn(len(children_map) + 1, block_structure) -@attr(shard=2) @ddt.ddt class TestBlockStructureData(TestCase, ChildrenMapTestMixin): """ Tests for BlockStructureBlockData and BlockStructureModulestoreData """ + shard = 2 + def test_non_versioned_transformer(self): class TestNonVersionedTransformer(MockTransformer): """ diff --git a/openedx/core/djangoapps/content/block_structure/tests/test_factory.py b/openedx/core/djangoapps/content/block_structure/tests/test_factory.py index 77fbbd2513..422cb0d9c6 100644 --- a/openedx/core/djangoapps/content/block_structure/tests/test_factory.py +++ b/openedx/core/djangoapps/content/block_structure/tests/test_factory.py @@ -2,7 +2,6 @@ Tests for block_structure_factory.py """ from django.test import TestCase -from nose.plugins.attrib import attr from xmodule.modulestore.exceptions import ItemNotFoundError from ..store import BlockStructureStore @@ -13,11 +12,12 @@ from .helpers import ( ) -@attr(shard=2) class TestBlockStructureFactory(TestCase, ChildrenMapTestMixin): """ Tests for BlockStructureFactory """ + shard = 2 + def setUp(self): super(TestBlockStructureFactory, self).setUp() self.children_map = self.SIMPLE_CHILDREN_MAP diff --git a/openedx/core/djangoapps/content/block_structure/tests/test_manager.py b/openedx/core/djangoapps/content/block_structure/tests/test_manager.py index 9c73af48c3..834051d0e4 100644 --- a/openedx/core/djangoapps/content/block_structure/tests/test_manager.py +++ b/openedx/core/djangoapps/content/block_structure/tests/test_manager.py @@ -3,7 +3,6 @@ Tests for manager.py """ import ddt from django.test import TestCase -from nose.plugins.attrib import attr from ..block_structure import BlockStructureBlockData from ..config import RAISE_ERROR_WHEN_NOT_FOUND, STORAGE_BACKING_FOR_CACHE, waffle @@ -89,12 +88,13 @@ class TestTransformer1(MockTransformer): return data_key + 't1.val1.' + unicode(block_key) -@attr(shard=2) @ddt.ddt class TestBlockStructureManager(UsageKeyFactoryMixin, ChildrenMapTestMixin, TestCase): """ Test class for BlockStructureManager. """ + shard = 2 + def setUp(self): super(TestBlockStructureManager, self).setUp() diff --git a/openedx/core/djangoapps/content/block_structure/tests/test_store.py b/openedx/core/djangoapps/content/block_structure/tests/test_store.py index 09c98026b1..9d9322de24 100644 --- a/openedx/core/djangoapps/content/block_structure/tests/test_store.py +++ b/openedx/core/djangoapps/content/block_structure/tests/test_store.py @@ -2,7 +2,6 @@ Tests for block_structure/cache.py """ import ddt -from nose.plugins.attrib import attr from openedx.core.djangolib.testing.utils import CacheIsolationTestCase @@ -13,13 +12,13 @@ from ..store import BlockStructureStore from .helpers import ChildrenMapTestMixin, UsageKeyFactoryMixin, MockCache, MockTransformer -@attr(shard=2) @ddt.ddt class TestBlockStructureStore(UsageKeyFactoryMixin, ChildrenMapTestMixin, CacheIsolationTestCase): """ Tests for BlockStructureStore """ ENABLED_CACHES = ['default'] + shard = 2 def setUp(self): super(TestBlockStructureStore, self).setUp() diff --git a/openedx/core/djangoapps/content/block_structure/tests/test_transformer_registry.py b/openedx/core/djangoapps/content/block_structure/tests/test_transformer_registry.py index 96ff1ffad4..7614b85edc 100644 --- a/openedx/core/djangoapps/content/block_structure/tests/test_transformer_registry.py +++ b/openedx/core/djangoapps/content/block_structure/tests/test_transformer_registry.py @@ -3,7 +3,6 @@ Tests for transformer_registry.py """ import ddt -from nose.plugins.attrib import attr from unittest import TestCase from ..transformer_registry import TransformerRegistry @@ -31,12 +30,13 @@ class UnregisteredTestTransformer3(MockTransformer): pass -@attr(shard=2) @ddt.ddt class TransformerRegistryTestCase(TestCase): """ Test cases for TransformerRegistry. """ + shard = 2 + def tearDown(self): super(TransformerRegistryTestCase, self).tearDown() clear_registered_transformers_cache() diff --git a/openedx/core/djangoapps/content/block_structure/tests/test_transformers.py b/openedx/core/djangoapps/content/block_structure/tests/test_transformers.py index 02f89ddbc0..9cbfe304e4 100644 --- a/openedx/core/djangoapps/content/block_structure/tests/test_transformers.py +++ b/openedx/core/djangoapps/content/block_structure/tests/test_transformers.py @@ -2,7 +2,6 @@ Tests for transformers.py """ from mock import MagicMock, patch -from nose.plugins.attrib import attr from unittest import TestCase from ..block_structure import BlockStructureModulestoreData @@ -13,11 +12,12 @@ from .helpers import ( ) -@attr(shard=2) class TestBlockStructureTransformers(ChildrenMapTestMixin, TestCase): """ Test class for testing BlockStructureTransformers """ + shard = 2 + class UnregisteredTransformer(MockTransformer): """ Mock transformer that is not registered. diff --git a/openedx/core/djangoapps/content/course_overviews/tests/test_course_overviews.py b/openedx/core/djangoapps/content/course_overviews/tests/test_course_overviews.py index bbb35b52fc..737a3c6768 100644 --- a/openedx/core/djangoapps/content/course_overviews/tests/test_course_overviews.py +++ b/openedx/core/djangoapps/content/course_overviews/tests/test_course_overviews.py @@ -7,7 +7,6 @@ import ddt import itertools import math import mock -from nose.plugins.attrib import attr import pytz from django.conf import settings @@ -41,13 +40,12 @@ from ..models import CourseOverview, CourseOverviewImageSet, CourseOverviewImage from .factories import CourseOverviewFactory -@attr(shard=3) @ddt.ddt class CourseOverviewTestCase(CatalogIntegrationMixin, ModuleStoreTestCase): """ Tests for CourseOverview model. """ - + shard = 3 TODAY = timezone.now() LAST_MONTH = 'last_month' LAST_WEEK = 'last_week' @@ -559,13 +557,13 @@ class CourseOverviewTestCase(CatalogIntegrationMixin, ModuleStoreTestCase): self.assertEqual(course_id_to_overview, None) -@attr(shard=3) @ddt.ddt class CourseOverviewImageSetTestCase(ModuleStoreTestCase): """ Course thumbnail generation tests. """ ENABLED_SIGNALS = ['course_published'] + shard = 3 def setUp(self): """Create an active CourseOverviewImageConfig with non-default values.""" @@ -1038,12 +1036,12 @@ class CourseOverviewImageSetTestCase(ModuleStoreTestCase): return course_overview -@attr(shard=3) @ddt.ddt class CourseOverviewTabTestCase(ModuleStoreTestCase): """ Tests for CourseOverviewTab model. """ + shard = 3 ENABLED_SIGNALS = ['course_published'] diff --git a/openedx/core/djangoapps/content/course_overviews/tests/test_signals.py b/openedx/core/djangoapps/content/course_overviews/tests/test_signals.py index 1f45535220..e806dd148c 100644 --- a/openedx/core/djangoapps/content/course_overviews/tests/test_signals.py +++ b/openedx/core/djangoapps/content/course_overviews/tests/test_signals.py @@ -1,7 +1,6 @@ import datetime import ddt from mock import patch -from nose.plugins.attrib import attr from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase @@ -11,7 +10,6 @@ from ..models import CourseOverview @ddt.ddt -@attr(shard=3) class CourseOverviewSignalsTestCase(ModuleStoreTestCase): """ Tests for CourseOverview signals. @@ -19,6 +17,7 @@ class CourseOverviewSignalsTestCase(ModuleStoreTestCase): ENABLED_SIGNALS = ['course_deleted', 'course_published'] TODAY = datetime.datetime.utcnow() NEXT_WEEK = TODAY + datetime.timedelta(days=7) + shard = 3 @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) def test_caching(self, modulestore_type): diff --git a/openedx/core/djangoapps/course_groups/tests/test_cohorts.py b/openedx/core/djangoapps/course_groups/tests/test_cohorts.py index ec57fe39e1..8c82b531d6 100644 --- a/openedx/core/djangoapps/course_groups/tests/test_cohorts.py +++ b/openedx/core/djangoapps/course_groups/tests/test_cohorts.py @@ -4,7 +4,6 @@ Tests for cohorts # pylint: disable=no-member import ddt from mock import call, patch -from nose.plugins.attrib import attr import before_after from django.contrib.auth.models import User @@ -29,12 +28,12 @@ from ..models import ( from ..tests.helpers import CohortFactory, CourseCohortFactory, config_course_cohorts, config_course_cohorts_legacy -@attr(shard=2) @patch("openedx.core.djangoapps.course_groups.cohorts.tracker", autospec=True) class TestCohortSignals(TestCase): """ Test cases to validate event emissions for various cohort-related workflows """ + shard = 2 def setUp(self): super(TestCohortSignals, self).setUp() @@ -135,13 +134,13 @@ class TestCohortSignals(TestCase): self.assertFalse(mock_tracker.emit.called) -@attr(shard=2) @ddt.ddt class TestCohorts(ModuleStoreTestCase): """ Test the cohorts feature """ MODULESTORE = TEST_DATA_MIXED_MODULESTORE + shard = 2 def setUp(self): """ @@ -729,13 +728,13 @@ class TestCohorts(ModuleStoreTestCase): self.assertEqual("Cohorted must be a boolean", text_type(value_error.exception)) -@attr(shard=2) @ddt.ddt class TestCohortsAndPartitionGroups(ModuleStoreTestCase): """ Test Cohorts and Partitions Groups. """ MODULESTORE = TEST_DATA_MIXED_MODULESTORE + shard = 2 def setUp(self): """ diff --git a/openedx/core/djangoapps/course_groups/tests/test_partition_scheme.py b/openedx/core/djangoapps/course_groups/tests/test_partition_scheme.py index 1e28ad2afd..403c77cd77 100644 --- a/openedx/core/djangoapps/course_groups/tests/test_partition_scheme.py +++ b/openedx/core/djangoapps/course_groups/tests/test_partition_scheme.py @@ -4,7 +4,6 @@ Test the partitions and partitions service """ import django.test from mock import patch -from nose.plugins.attrib import attr from courseware.tests.test_masquerade import StaffMasqueradeTestCase from student.tests.factories import UserFactory @@ -15,6 +14,7 @@ from xmodule.modulestore.tests.factories import ToyCourseFactory from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme from openedx.core.djangolib.testing.utils import skip_unless_lms +from openedx.core.lib.tests import attr from ..partition_scheme import CohortPartitionScheme, get_cohorted_user_partition from ..models import CourseUserGroupPartitionGroup from ..views import link_cohort_to_partition_group, unlink_cohort_partition_group diff --git a/openedx/core/djangoapps/course_groups/tests/test_views.py b/openedx/core/djangoapps/course_groups/tests/test_views.py index 978b87fe10..1032b18d68 100644 --- a/openedx/core/djangoapps/course_groups/tests/test_views.py +++ b/openedx/core/djangoapps/course_groups/tests/test_views.py @@ -6,14 +6,13 @@ Tests for course group views import json from collections import namedtuple -from nose.plugins.attrib import attr - from django.contrib.auth.models import User from django.http import Http404 from django.test.client import RequestFactory from django_comment_common.models import CourseDiscussionSettings from django_comment_common.utils import get_course_discussion_settings from opaque_keys.edx.locator import CourseLocator +from openedx.core.lib.tests import attr from student.models import CourseEnrollment from student.tests.factories import UserFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase diff --git a/openedx/core/djangoapps/credentials/tests/test_models.py b/openedx/core/djangoapps/credentials/tests/test_models.py index 83b78b77cb..73bbfdb3ea 100644 --- a/openedx/core/djangoapps/credentials/tests/test_models.py +++ b/openedx/core/djangoapps/credentials/tests/test_models.py @@ -1,7 +1,6 @@ """Tests for models supporting Credentials-related functionality.""" from django.test import TestCase, override_settings -from nose.plugins.attrib import attr from openedx.core.djangoapps.credentials.models import API_VERSION from openedx.core.djangoapps.credentials.tests.mixins import CredentialsApiConfigMixin @@ -12,9 +11,9 @@ CREDENTIALS_PUBLIC_SERVICE_URL = 'https://credentials.example.com' @skip_unless_lms -@attr(shard=2) class TestCredentialsApiConfig(CredentialsApiConfigMixin, TestCase): """Tests covering the CredentialsApiConfig model.""" + shard = 2 @override_settings( CREDENTIALS_INTERNAL_SERVICE_URL=CREDENTIALS_INTERNAL_SERVICE_URL, diff --git a/openedx/core/djangoapps/credentials/tests/test_utils.py b/openedx/core/djangoapps/credentials/tests/test_utils.py index ad525b1da7..52356290e3 100644 --- a/openedx/core/djangoapps/credentials/tests/test_utils.py +++ b/openedx/core/djangoapps/credentials/tests/test_utils.py @@ -3,7 +3,6 @@ import uuid from edx_oauth2_provider.tests.factories import ClientFactory import mock -from nose.plugins.attrib import attr from provider.constants import CONFIDENTIAL from openedx.core.djangoapps.credentials.models import CredentialsApiConfig @@ -18,10 +17,10 @@ UTILS_MODULE = 'openedx.core.djangoapps.credentials.utils' @skip_unless_lms -@attr(shard=2) @mock.patch(UTILS_MODULE + '.get_edx_api_data') class TestGetCredentials(CredentialsApiConfigMixin, CacheIsolationTestCase): """ Tests for credentials utility functions. """ + shard = 2 ENABLED_CACHES = ['default'] diff --git a/openedx/core/djangoapps/credit/tests/test_api.py b/openedx/core/djangoapps/credit/tests/test_api.py index 6cacc71fa4..39d9f6c59b 100644 --- a/openedx/core/djangoapps/credit/tests/test_api.py +++ b/openedx/core/djangoapps/credit/tests/test_api.py @@ -12,7 +12,6 @@ from django.contrib.auth.models import User from django.core import mail from django.db import connection from django.test.utils import override_settings -from nose.plugins.attrib import attr from opaque_keys.edx.keys import CourseKey from course_modes.models import CourseMode @@ -202,13 +201,13 @@ class CreditApiTestBase(ModuleStoreTestCase): ) -@attr(shard=2) @skip_unless_lms @ddt.ddt class CreditRequirementApiTests(CreditApiTestBase): """ Test Python API for credit requirements and eligibility. """ + shard = 2 @ddt.data( [ @@ -874,12 +873,12 @@ class CreditRequirementApiTests(CreditApiTestBase): self.assertIn(providers_email_message, text_content_first) -@attr(shard=2) @ddt.ddt class CreditProviderIntegrationApiTests(CreditApiTestBase): """ Test Python API for credit provider integration. """ + shard = 2 USER_INFO = { "username": "bob", @@ -1201,7 +1200,6 @@ class CreditProviderIntegrationApiTests(CreditApiTestBase): self.assertEqual(statuses[0]["status"], expected_status) -@attr(shard=2) @skip_unless_lms @override_settings( ECOMMERCE_API_URL=TEST_API_URL, @@ -1210,6 +1208,8 @@ class CreditProviderIntegrationApiTests(CreditApiTestBase): @ddt.ddt class CourseApiTests(CreditApiTestBase): """Test Python API for course product information.""" + shard = 2 + def setUp(self): super(CourseApiTests, self).setUp() self.worker_user = User.objects.create_user(username=TEST_ECOMMERCE_WORKER) diff --git a/openedx/core/djangoapps/credit/tests/test_models.py b/openedx/core/djangoapps/credit/tests/test_models.py index da957c1041..235300b703 100644 --- a/openedx/core/djangoapps/credit/tests/test_models.py +++ b/openedx/core/djangoapps/credit/tests/test_models.py @@ -5,7 +5,6 @@ Tests for credit course models. import ddt from django.test import TestCase -from nose.plugins.attrib import attr from opaque_keys.edx.keys import CourseKey from openedx.core.djangoapps.credit.models import ( @@ -31,12 +30,12 @@ def add_credit_course(course_key): return credit_course -@attr(shard=2) @ddt.ddt class CreditEligibilityModelTests(TestCase): """ Tests for credit models used to track credit eligibility. """ + shard = 2 def setUp(self): super(CreditEligibilityModelTests, self).setUp() diff --git a/openedx/core/djangoapps/credit/tests/test_serializers.py b/openedx/core/djangoapps/credit/tests/test_serializers.py index b3eccb007c..e3a59f84e2 100644 --- a/openedx/core/djangoapps/credit/tests/test_serializers.py +++ b/openedx/core/djangoapps/credit/tests/test_serializers.py @@ -5,15 +5,14 @@ from __future__ import unicode_literals from django.test import TestCase -from nose.plugins.attrib import attr from openedx.core.djangoapps.credit import serializers from openedx.core.djangoapps.credit.tests.factories import CreditProviderFactory, CreditEligibilityFactory from student.tests.factories import UserFactory -@attr(shard=2) class CreditProviderSerializerTests(TestCase): """ CreditProviderSerializer tests. """ + shard = 2 def test_data(self): """ Verify the correct fields are serialized. """ @@ -32,9 +31,9 @@ class CreditProviderSerializerTests(TestCase): self.assertDictEqual(serializer.data, expected) -@attr(shard=2) class CreditEligibilitySerializerTests(TestCase): """ CreditEligibilitySerializer tests. """ + shard = 2 def test_data(self): """ Verify the correct fields are serialized. """ diff --git a/openedx/core/djangoapps/credit/tests/test_services.py b/openedx/core/djangoapps/credit/tests/test_services.py index 60b0f83521..220bc5a96b 100644 --- a/openedx/core/djangoapps/credit/tests/test_services.py +++ b/openedx/core/djangoapps/credit/tests/test_services.py @@ -3,7 +3,6 @@ Tests for the Credit xBlock service """ import ddt -from nose.plugins.attrib import attr from course_modes.models import CourseMode from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase @@ -16,12 +15,12 @@ from openedx.core.djangoapps.credit.api.eligibility import set_credit_requiremen from student.models import CourseEnrollment, UserProfile -@attr(shard=2) @ddt.ddt class CreditServiceTests(ModuleStoreTestCase): """ Tests for the Credit xBlock service """ + shard = 2 def setUp(self, **kwargs): super(CreditServiceTests, self).setUp() diff --git a/openedx/core/djangoapps/credit/tests/test_signals.py b/openedx/core/djangoapps/credit/tests/test_signals.py index ead33b5574..06323db8fd 100644 --- a/openedx/core/djangoapps/credit/tests/test_signals.py +++ b/openedx/core/djangoapps/credit/tests/test_signals.py @@ -8,7 +8,6 @@ from datetime import timedelta, datetime from mock import MagicMock from django.test.client import RequestFactory -from nose.plugins.attrib import attr from course_modes.models import CourseMode from student.models import CourseEnrollment from student.tests.factories import UserFactory @@ -23,7 +22,6 @@ from openedx.core.djangoapps.credit.signals import listen_for_grade_calculation from openedx.core.djangolib.testing.utils import skip_unless_lms -@attr(shard=2) @skip_unless_lms @ddt.ddt class TestMinGradedRequirementStatus(ModuleStoreTestCase): @@ -34,6 +32,7 @@ class TestMinGradedRequirementStatus(ModuleStoreTestCase): """ VALID_DUE_DATE = datetime.now(pytz.UTC) + timedelta(days=20) EXPIRED_DUE_DATE = datetime.now(pytz.UTC) - timedelta(days=20) + shard = 2 DATES = { 'valid': VALID_DUE_DATE, diff --git a/openedx/core/djangoapps/credit/tests/test_signature.py b/openedx/core/djangoapps/credit/tests/test_signature.py index e8e5ae6a82..d90b0d5759 100644 --- a/openedx/core/djangoapps/credit/tests/test_signature.py +++ b/openedx/core/djangoapps/credit/tests/test_signature.py @@ -3,16 +3,12 @@ Tests for digital signatures used to validate messages to/from credit providers. """ -from nose.plugins.attrib import attr - from django.test import TestCase from django.test.utils import override_settings - from openedx.core.djangoapps.credit import signature -@attr(shard=2) @override_settings(CREDIT_PROVIDER_SECRET_KEYS={ "asu": u'abcd1234' }) @@ -20,6 +16,7 @@ class SignatureTest(TestCase): """ Tests for digital signatures. """ + shard = 2 def test_unicode_secret_key(self): # Test a key that has type `unicode` but consists of ASCII characters diff --git a/openedx/core/djangoapps/credit/tests/test_tasks.py b/openedx/core/djangoapps/credit/tests/test_tasks.py index ea7b02dfef..05b6bed543 100644 --- a/openedx/core/djangoapps/credit/tests/test_tasks.py +++ b/openedx/core/djangoapps/credit/tests/test_tasks.py @@ -3,7 +3,6 @@ Tests for credit course tasks. """ import mock -from nose.plugins.attrib import attr from datetime import datetime from openedx.core.djangoapps.credit.api import get_credit_requirements @@ -16,7 +15,6 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from edx_proctoring.api import create_exam -@attr(shard=2) class TestTaskExecution(ModuleStoreTestCase): """Set of tests to ensure that the task code will do the right thing when executed directly. @@ -25,6 +23,7 @@ class TestTaskExecution(ModuleStoreTestCase): allows us to ensure that when the listener is executed, it is done as expected. """ + shard = 2 def mocked_set_credit_requirements(course_key, requirements): # pylint: disable=no-self-argument, unused-argument """Used as a side effect when mocking method credit api method diff --git a/openedx/core/djangoapps/credit/tests/test_views.py b/openedx/core/djangoapps/credit/tests/test_views.py index a61f80e054..7dba5197b1 100644 --- a/openedx/core/djangoapps/credit/tests/test_views.py +++ b/openedx/core/djangoapps/credit/tests/test_views.py @@ -16,7 +16,6 @@ from django.urls import reverse from django.test import TestCase, Client from django.test.utils import override_settings from edx_oauth2_provider.tests.factories import AccessTokenFactory, ClientFactory -from nose.plugins.attrib import attr from opaque_keys.edx.keys import CourseKey from openedx.core.djangoapps.credit.models import ( @@ -28,6 +27,7 @@ from openedx.core.djangoapps.credit.tests.factories import ( CreditProviderFactory, CreditEligibilityFactory, CreditCourseFactory, CreditRequestFactory, ) from openedx.core.djangolib.testing.utils import skip_unless_lms +from openedx.core.lib.tests import attr from openedx.core.lib.token_utils import JwtBuilder from student.tests.factories import UserFactory, AdminFactory from util.date_utils import to_timestamp diff --git a/openedx/core/djangoapps/embargo/tests/test_api.py b/openedx/core/djangoapps/embargo/tests/test_api.py index 7f17010fc7..40e7454e60 100644 --- a/openedx/core/djangoapps/embargo/tests/test_api.py +++ b/openedx/core/djangoapps/embargo/tests/test_api.py @@ -4,7 +4,6 @@ Tests for EmbargoMiddleware from contextlib import contextmanager import mock -from nose.plugins.attrib import attr import pygeoip import ddt @@ -38,14 +37,13 @@ from mock import patch MODULESTORE_CONFIG = mixed_store_config(settings.COMMON_TEST_DATA_ROOT, {}) -@attr(shard=3) @ddt.ddt @override_settings(MODULESTORE=MODULESTORE_CONFIG) @skip_unless_lms @mock.patch.dict(settings.FEATURES, {'EMBARGO': True}) class EmbargoCheckAccessApiTests(ModuleStoreTestCase): """Test the embargo API calls to determine whether a user has access. """ - + shard = 3 ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache'] def setUp(self): diff --git a/openedx/core/djangoapps/embargo/tests/test_middleware.py b/openedx/core/djangoapps/embargo/tests/test_middleware.py index 83563f0a10..bec533c7f4 100644 --- a/openedx/core/djangoapps/embargo/tests/test_middleware.py +++ b/openedx/core/djangoapps/embargo/tests/test_middleware.py @@ -3,7 +3,6 @@ Tests for EmbargoMiddleware with CountryAccessRules """ from mock import patch -from nose.plugins.attrib import attr import ddt from django.urls import reverse @@ -21,7 +20,6 @@ from ..models import RestrictedCourse, IPFilter from ..test_utils import restrict_course -@attr(shard=3) @ddt.ddt @skip_unless_lms class EmbargoMiddlewareAccessTests(UrlResetMixin, ModuleStoreTestCase): @@ -36,6 +34,7 @@ class EmbargoMiddlewareAccessTests(UrlResetMixin, ModuleStoreTestCase): PASSWORD = 'secret' URLCONF_MODULES = ['openedx.core.djangoapps.embargo'] + shard = 3 @patch.dict(settings.FEATURES, {'EMBARGO': True}) def setUp(self): diff --git a/openedx/core/djangoapps/external_auth/tests/test_shib.py b/openedx/core/djangoapps/external_auth/tests/test_shib.py index c89bbfdbc5..ad5339c33b 100644 --- a/openedx/core/djangoapps/external_auth/tests/test_shib.py +++ b/openedx/core/djangoapps/external_auth/tests/test_shib.py @@ -8,7 +8,6 @@ import unittest from importlib import import_module from urllib import urlencode -import pytest from ddt import ddt, data from django.conf import settings from django.http import HttpResponseRedirect @@ -23,7 +22,6 @@ from openedx.core.djangoapps.external_auth.views import ( ) from openedx.core.djangoapps.user_api import accounts as accounts_settings from mock import patch -from nose.plugins.attrib import attr from six import text_type from openedx.core.djangolib.testing.utils import CacheIsolationTestCase @@ -77,7 +75,6 @@ def gen_all_identities(): yield _build_identity_dict(mail, display_name, given_name, surname) -@attr(shard=3) @ddt @override_settings(SESSION_ENGINE='django.contrib.sessions.backends.cache') class ShibSPTest(CacheIsolationTestCase): @@ -85,6 +82,7 @@ class ShibSPTest(CacheIsolationTestCase): Tests for the Shibboleth SP, which communicates via request.META (Apache environment variables set by mod_shib) """ + shard = 3 ENABLED_CACHES = ['default'] diff --git a/openedx/core/djangoapps/models/tests/test_course_details.py b/openedx/core/djangoapps/models/tests/test_course_details.py index 0d51d2a475..9a0476ec42 100644 --- a/openedx/core/djangoapps/models/tests/test_course_details.py +++ b/openedx/core/djangoapps/models/tests/test_course_details.py @@ -5,7 +5,6 @@ Tests for CourseDetails import datetime import ddt from pytz import UTC -from nose.plugins.attrib import attr from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase @@ -14,12 +13,13 @@ from xmodule.modulestore.tests.factories import CourseFactory from openedx.core.djangoapps.models.course_details import CourseDetails, ABOUT_ATTRIBUTES -@attr(shard=2) @ddt.ddt class CourseDetailsTestCase(ModuleStoreTestCase): """ Tests the first course settings page (course dates, overview, etc.). """ + shard = 2 + def setUp(self): super(CourseDetailsTestCase, self).setUp() self.course = CourseFactory.create() diff --git a/openedx/core/djangoapps/profile_images/tests/test_images.py b/openedx/core/djangoapps/profile_images/tests/test_images.py index 17c3e40db5..bbd43a178b 100644 --- a/openedx/core/djangoapps/profile_images/tests/test_images.py +++ b/openedx/core/djangoapps/profile_images/tests/test_images.py @@ -11,7 +11,6 @@ from django.test import TestCase from django.test.utils import override_settings import ddt import mock -from nose.plugins.attrib import attr import piexif from PIL import Image from six import text_type @@ -29,7 +28,6 @@ from ..images import ( from .helpers import make_image_file, make_uploaded_file -@attr(shard=2) @ddt.ddt @skip_unless_lms class TestValidateUploadedImage(TestCase): @@ -41,6 +39,7 @@ class TestValidateUploadedImage(TestCase): valid_file_types=_get_valid_file_types() ) ) + shard = 2 def check_validation_result(self, uploaded_file, expected_failure_message): """ @@ -125,13 +124,13 @@ class TestValidateUploadedImage(TestCase): self.assertEqual(text_type(ctx.exception), file_upload_bad_mimetype) -@attr(shard=2) @ddt.ddt @skip_unless_lms class TestGenerateProfileImages(TestCase): """ Test create_profile_images """ + shard = 2 def check_exif_orientation(self, image, expected_orientation): """ @@ -223,12 +222,13 @@ class TestGenerateProfileImages(TestCase): yield name, image -@attr(shard=2) @skip_unless_lms class TestRemoveProfileImages(TestCase): """ Test remove_profile_images """ + shard = 2 + def test_remove(self): """ Ensure that the outcome of calling the function is that the named images diff --git a/openedx/core/djangoapps/profile_images/tests/test_views.py b/openedx/core/djangoapps/profile_images/tests/test_views.py index 09898364f9..d260869b19 100644 --- a/openedx/core/djangoapps/profile_images/tests/test_views.py +++ b/openedx/core/djangoapps/profile_images/tests/test_views.py @@ -3,7 +3,6 @@ Test cases for the HTTP endpoints of the profile image api. """ from contextlib import closing import datetime -from nose.plugins.attrib import attr from pytz import UTC from django.urls import reverse @@ -23,6 +22,7 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import ( get_profile_image_storage, ) from openedx.core.djangolib.testing.utils import skip_unless_lms +from openedx.core.lib.tests import attr from ..images import create_profile_images, ImageValidationError from ..views import LOG_MESSAGE_CREATE, LOG_MESSAGE_DELETE diff --git a/openedx/core/djangoapps/programs/tests/test_signals.py b/openedx/core/djangoapps/programs/tests/test_signals.py index 4ba09c4a3e..52970e1724 100644 --- a/openedx/core/djangoapps/programs/tests/test_signals.py +++ b/openedx/core/djangoapps/programs/tests/test_signals.py @@ -3,7 +3,6 @@ This module contains tests for programs-related signals and signal handlers. """ from django.test import TestCase -from nose.plugins.attrib import attr import mock from opaque_keys.edx.keys import CourseKey @@ -18,7 +17,6 @@ TEST_USERNAME = 'test-user' TEST_COURSE_KEY = CourseKey.from_string('course-v1:edX+test_course+1') -@attr(shard=2) # The credentials app isn't installed for the CMS. @skip_unless_lms @mock.patch('openedx.core.djangoapps.programs.tasks.v1.tasks.award_program_certificates.delay') @@ -31,6 +29,7 @@ class CertAwardedReceiverTest(TestCase): """ Tests for the `handle_course_cert_awarded` signal handler function. """ + shard = 2 @property def signal_kwargs(self): @@ -80,7 +79,6 @@ class CertAwardedReceiverTest(TestCase): self.assertEqual(mock_task.call_args[0], (TEST_USERNAME,)) -@attr(shard=2) # The credentials app isn't installed for the CMS. @skip_unless_lms @mock.patch('openedx.core.djangoapps.programs.tasks.v1.tasks.award_course_certificate.delay') @@ -93,6 +91,7 @@ class CertChangedReceiverTest(TestCase): """ Tests for the `handle_course_cert_changed` signal handler function. """ + shard = 2 def setUp(self): super(CertChangedReceiverTest, self).setUp() diff --git a/openedx/core/djangoapps/programs/tests/test_utils.py b/openedx/core/djangoapps/programs/tests/test_utils.py index fe7f0c1ab1..374c34c228 100644 --- a/openedx/core/djangoapps/programs/tests/test_utils.py +++ b/openedx/core/djangoapps/programs/tests/test_utils.py @@ -12,7 +12,6 @@ from django.conf import settings from django.urls import reverse from django.test import TestCase from django.test.utils import override_settings -from nose.plugins.attrib import attr from pytz import utc from course_modes.models import CourseMode @@ -57,11 +56,12 @@ UTILS_MODULE = 'openedx.core.djangoapps.programs.utils' @ddt.ddt -@attr(shard=2) @skip_unless_lms @mock.patch(UTILS_MODULE + '.get_programs') class TestProgramProgressMeter(TestCase): """Tests of the program progress utility class.""" + shard = 2 + def setUp(self): super(TestProgramProgressMeter, self).setUp() diff --git a/openedx/core/djangoapps/safe_sessions/tests/test_middleware.py b/openedx/core/djangoapps/safe_sessions/tests/test_middleware.py index 20a676abb7..452ca25c9e 100644 --- a/openedx/core/djangoapps/safe_sessions/tests/test_middleware.py +++ b/openedx/core/djangoapps/safe_sessions/tests/test_middleware.py @@ -11,7 +11,6 @@ from django.http import HttpResponse, HttpResponseRedirect, SimpleCookie from django.test import TestCase from django.test.utils import override_settings from mock import patch -from nose.plugins.attrib import attr from openedx.core.djangolib.testing.utils import get_mock_request @@ -21,11 +20,12 @@ from ..middleware import SafeSessionMiddleware, SafeCookieData from .test_utils import TestSafeSessionsLogMixin -@attr(shard=2) class TestSafeSessionProcessRequest(TestSafeSessionsLogMixin, TestCase): """ Test class for SafeSessionMiddleware.process_request """ + shard = 2 + def setUp(self): super(TestSafeSessionProcessRequest, self).setUp() self.user = UserFactory.create() @@ -122,12 +122,13 @@ class TestSafeSessionProcessRequest(TestSafeSessionsLogMixin, TestCase): self.assert_user_in_session() -@attr(shard=2) @ddt.ddt class TestSafeSessionProcessResponse(TestSafeSessionsLogMixin, TestCase): """ Test class for SafeSessionMiddleware.process_response """ + shard = 2 + def setUp(self): super(TestSafeSessionProcessResponse, self).setUp() self.user = UserFactory.create() @@ -225,13 +226,14 @@ class TestSafeSessionProcessResponse(TestSafeSessionsLogMixin, TestCase): self.assert_response_with_delete_cookie() -@attr(shard=2) @ddt.ddt class TestSafeSessionMiddleware(TestSafeSessionsLogMixin, TestCase): """ Test class for SafeSessionMiddleware, testing both process_request and process_response. """ + shard = 2 + def setUp(self): super(TestSafeSessionMiddleware, self).setUp() self.user = UserFactory.create() diff --git a/openedx/core/djangoapps/safe_sessions/tests/test_safe_cookie_data.py b/openedx/core/djangoapps/safe_sessions/tests/test_safe_cookie_data.py index 016d80521a..338d068b63 100644 --- a/openedx/core/djangoapps/safe_sessions/tests/test_safe_cookie_data.py +++ b/openedx/core/djangoapps/safe_sessions/tests/test_safe_cookie_data.py @@ -7,19 +7,19 @@ import ddt from django.test import TestCase import itertools from mock import patch -from nose.plugins.attrib import attr from time import time from ..middleware import SafeCookieData, SafeCookieError from .test_utils import TestSafeSessionsLogMixin -@attr(shard=2) @ddt.ddt class TestSafeCookieData(TestSafeSessionsLogMixin, TestCase): """ Test class for SafeCookieData """ + shard = 2 + def setUp(self): super(TestSafeCookieData, self).setUp() self.session_id = 'test_session_id' diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_api.py b/openedx/core/djangoapps/user_api/accounts/tests/test_api.py index 6e3c08bf71..33d3bcba67 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_api.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_api.py @@ -15,7 +15,6 @@ from django.core import mail from django.test import TestCase from django.test.client import RequestFactory from mock import Mock, patch -from nose.plugins.attrib import attr from nose.tools import raises from six import iteritems @@ -48,6 +47,7 @@ from openedx.core.djangoapps.user_api.errors import ( UserNotFound ) from openedx.core.djangolib.testing.utils import skip_unless_lms +from openedx.core.lib.tests import attr from student.models import PendingEmailChange from student.tests.factories import UserFactory from student.tests.tests import UserSettingsEventTestMixin diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py b/openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py index ddd9f961e5..f7e4ffdd14 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py @@ -4,7 +4,6 @@ Tests for helpers.py import datetime import hashlib from mock import patch -from nose.plugins.attrib import attr from pytz import UTC from django.test import TestCase @@ -17,13 +16,14 @@ TEST_SIZES = {'full': 50, 'small': 10} TEST_PROFILE_IMAGE_UPLOAD_DT = datetime.datetime(2002, 1, 9, 15, 43, 01, tzinfo=UTC) -@attr(shard=2) @patch.dict('django.conf.settings.PROFILE_IMAGE_SIZES_MAP', TEST_SIZES, clear=True) @skip_unless_lms class ProfileImageUrlTestCase(TestCase): """ Tests for profile image URL generation helpers. """ + shard = 2 + def setUp(self): super(ProfileImageUrlTestCase, self).setUp() self.user = UserFactory() diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_views.py b/openedx/core/djangoapps/user_api/accounts/tests/test_views.py index d7bf00022e..e682d99871 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_views.py @@ -14,7 +14,6 @@ from django.test.testcases import TransactionTestCase from django.test.utils import override_settings import mock -from nose.plugins.attrib import attr import pytz from rest_framework.test import APIClient, APITestCase @@ -162,11 +161,11 @@ class UserAPITestCase(APITestCase): @ddt.ddt @skip_unless_lms -@attr(shard=2) class TestOwnUsernameAPI(CacheIsolationTestCase, UserAPITestCase): """ Unit tests for the Accounts API. """ + shard = 2 ENABLED_CACHES = ['default'] @@ -221,11 +220,11 @@ class TestOwnUsernameAPI(CacheIsolationTestCase, UserAPITestCase): {'full': 50, 'small': 10}, clear=True ) -@attr(shard=2) class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): """ Unit tests for the Accounts API. """ + shard = 2 ENABLED_CACHES = ['default'] @@ -812,12 +811,12 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): ) -@attr(shard=2) @skip_unless_lms class TestAccountAPITransactions(TransactionTestCase): """ Tests the transactional behavior of the account API """ + shard = 2 def setUp(self): super(TestAccountAPITransactions, self).setUp() diff --git a/openedx/core/djangoapps/user_api/course_tag/tests/test_api.py b/openedx/core/djangoapps/user_api/course_tag/tests/test_api.py index 2a55df15f1..ca3f633465 100644 --- a/openedx/core/djangoapps/user_api/course_tag/tests/test_api.py +++ b/openedx/core/djangoapps/user_api/course_tag/tests/test_api.py @@ -4,16 +4,16 @@ Test the user course tag API. from django.test import TestCase from student.tests.factories import UserFactory -from nose.plugins.attrib import attr from openedx.core.djangoapps.user_api.course_tag import api as course_tag_api from opaque_keys.edx.locator import CourseLocator -@attr(shard=2) class TestCourseTagAPI(TestCase): """ Test the user service """ + shard = 2 + def setUp(self): super(TestCourseTagAPI, self).setUp() self.user = UserFactory.create() diff --git a/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py b/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py index 332f7fbe95..a367514667 100644 --- a/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py +++ b/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py @@ -5,7 +5,6 @@ import tempfile import shutil import csv from collections import defaultdict -from nose.plugins.attrib import attr import ddt from django.contrib.auth.models import User @@ -24,12 +23,11 @@ from openedx.core.djangoapps.user_api.management.commands import email_opt_in_li from openedx.core.djangolib.testing.utils import skip_unless_lms -@attr(shard=2) @ddt.ddt @skip_unless_lms class EmailOptInListTest(ModuleStoreTestCase): """Tests for the email opt-in list management command. """ - + shard = 2 USER_USERNAME = "test_user" USER_FIRST_NAME = u"Ṫëṡẗ" USER_LAST_NAME = u"Űśéŕ" diff --git a/openedx/core/djangoapps/user_api/preferences/tests/test_api.py b/openedx/core/djangoapps/user_api/preferences/tests/test_api.py index 5acaca5afe..5df93fcc8c 100644 --- a/openedx/core/djangoapps/user_api/preferences/tests/test_api.py +++ b/openedx/core/djangoapps/user_api/preferences/tests/test_api.py @@ -5,7 +5,6 @@ Unit tests for preference APIs. import datetime import ddt from mock import patch -from nose.plugins.attrib import attr from pytz import common_timezones, utc from django.contrib.auth.models import User @@ -40,7 +39,6 @@ from ...preferences.api import ( ) -@attr(shard=2) @skip_unless_lms class TestPreferenceAPI(CacheIsolationTestCase): """ @@ -49,6 +47,7 @@ class TestPreferenceAPI(CacheIsolationTestCase): are not specified. """ password = "test" + shard = 2 def setUp(self): super(TestPreferenceAPI, self).setUp() @@ -328,7 +327,6 @@ class TestPreferenceAPI(CacheIsolationTestCase): ) -@attr(shard=2) @ddt.ddt class UpdateEmailOptInTests(ModuleStoreTestCase): """ @@ -337,6 +335,7 @@ class UpdateEmailOptInTests(ModuleStoreTestCase): USERNAME = u'frank-underwood' PASSWORD = u'ṕáśśẃőŕd' EMAIL = u'frank+underwood@example.com' + shard = 2 @ddt.data( # Check that a 27 year old can opt-in diff --git a/openedx/core/djangoapps/verified_track_content/tests/test_views.py b/openedx/core/djangoapps/verified_track_content/tests/test_views.py index dfc80affbb..b59b0d88fb 100644 --- a/openedx/core/djangoapps/verified_track_content/tests/test_views.py +++ b/openedx/core/djangoapps/verified_track_content/tests/test_views.py @@ -4,8 +4,6 @@ Tests for verified track content views. import json -from nose.plugins.attrib import attr - from django.http import Http404 from django.test.client import RequestFactory @@ -18,12 +16,12 @@ from ..models import VerifiedTrackCohortedCourse from ..views import cohorting_settings -@attr(shard=2) @skip_unless_lms class CohortingSettingsTestCase(SharedModuleStoreTestCase): """ Tests the `cohort_discussion_topics` view. """ + shard = 2 @classmethod def setUpClass(cls): diff --git a/openedx/core/djangolib/tests/test_js_utils.py b/openedx/core/djangolib/tests/test_js_utils.py index 495a211405..a569fdb780 100644 --- a/openedx/core/djangolib/tests/test_js_utils.py +++ b/openedx/core/djangolib/tests/test_js_utils.py @@ -7,16 +7,15 @@ import json from unittest import TestCase from mako.template import Template -from nose.plugins.attrib import attr from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string -@attr(shard=2) class TestJSUtils(TestCase): """ Test JS utils """ + shard = 2 class NoDefaultEncoding(object): """ diff --git a/openedx/core/djangolib/tests/test_markup.py b/openedx/core/djangolib/tests/test_markup.py index 6aafb86209..b870074730 100644 --- a/openedx/core/djangolib/tests/test_markup.py +++ b/openedx/core/djangolib/tests/test_markup.py @@ -9,15 +9,14 @@ import ddt from django.utils.translation import ugettext as _ from django.utils.translation import ungettext from mako.template import Template -from nose.plugins.attrib import attr from openedx.core.djangolib.markup import HTML, Text, strip_all_tags_but_br -@attr(shard=2) @ddt.ddt class FormatHtmlTest(unittest.TestCase): """Test that we can format plain strings and HTML into them properly.""" + shard = 2 @ddt.data( (u"hello", u"hello"), diff --git a/openedx/core/lib/api/tests/test_authentication.py b/openedx/core/lib/api/tests/test_authentication.py index c0ee2e0af1..66c77d8ec9 100644 --- a/openedx/core/lib/api/tests/test_authentication.py +++ b/openedx/core/lib/api/tests/test_authentication.py @@ -20,7 +20,6 @@ from django.test import TestCase from django.test.utils import override_settings from django.utils.http import urlencode from django.utils.timezone import now -from nose.plugins.attrib import attr from oauth2_provider import models as dot_models from rest_framework import status from rest_framework.permissions import IsAuthenticated @@ -73,12 +72,13 @@ urlpatterns = [ ] -@attr(shard=2) @ddt.ddt @unittest.skipUnless(settings.FEATURES.get("ENABLE_OAUTH2_PROVIDER"), "OAuth2 not enabled") @override_settings(ROOT_URLCONF=__name__) class OAuth2Tests(TestCase): """OAuth 2.0 authentication""" + shard = 2 + def setUp(self): super(OAuth2Tests, self).setUp() self.dop_adapter = adapters.DOPAdapter() diff --git a/openedx/core/lib/api/tests/test_exceptions.py b/openedx/core/lib/api/tests/test_exceptions.py index a55635ae75..170cb8f0dd 100644 --- a/openedx/core/lib/api/tests/test_exceptions.py +++ b/openedx/core/lib/api/tests/test_exceptions.py @@ -3,16 +3,15 @@ Test Custom Exceptions """ import ddt from django.test import TestCase -from nose.plugins.attrib import attr from rest_framework import exceptions as drf_exceptions -@attr(shard=2) @ddt.ddt class TestDictExceptionsAllowDictDetails(TestCase): """ Test that standard DRF exceptions can return dictionaries in error details. """ + shard = 2 def test_drf_errors_are_not_coerced_to_strings(self): # Demonstrate that dictionaries in exceptions are not coerced to strings. diff --git a/openedx/core/lib/api/tests/test_parsers.py b/openedx/core/lib/api/tests/test_parsers.py index fb0b4b4cdd..4b2e403d83 100644 --- a/openedx/core/lib/api/tests/test_parsers.py +++ b/openedx/core/lib/api/tests/test_parsers.py @@ -3,7 +3,6 @@ TestCases verifying proper behavior of custom DRF request parsers. """ from collections import namedtuple -from nose.plugins.attrib import attr from io import BytesIO from rest_framework import exceptions @@ -12,11 +11,12 @@ from rest_framework.test import APITestCase, APIRequestFactory from openedx.core.lib.api import parsers -@attr(shard=2) class TestTypedFileUploadParser(APITestCase): """ Tests that verify the behavior of TypedFileUploadParser """ + shard = 2 + def setUp(self): super(TestTypedFileUploadParser, self).setUp() self.parser = parsers.TypedFileUploadParser() diff --git a/openedx/core/lib/api/tests/test_permissions.py b/openedx/core/lib/api/tests/test_permissions.py index e9b3003815..b13e33889a 100644 --- a/openedx/core/lib/api/tests/test_permissions.py +++ b/openedx/core/lib/api/tests/test_permissions.py @@ -4,7 +4,6 @@ import ddt from django.contrib.auth.models import AnonymousUser from django.http import Http404 from django.test import TestCase, RequestFactory -from nose.plugins.attrib import attr from rest_framework.generics import GenericAPIView from student.roles import CourseStaffRole, CourseInstructorRole @@ -31,9 +30,9 @@ class TestCcxObject(TestObject): self.coach = user -@attr(shard=2) class IsCourseStaffInstructorTests(TestCase): """ Test for IsCourseStaffInstructor permission class. """ + shard = 2 def setUp(self): super(IsCourseStaffInstructorTests, self).setUp() @@ -65,9 +64,9 @@ class IsCourseStaffInstructorTests(TestCase): self.assertFalse(self.permission.has_object_permission(self.request, None, self.obj)) -@attr(shard=2) class IsMasterCourseStaffInstructorTests(TestCase): """ Test for IsMasterCourseStaffInstructorTests permission class. """ + shard = 2 def setUp(self): super(IsMasterCourseStaffInstructorTests, self).setUp() @@ -110,10 +109,10 @@ class IsMasterCourseStaffInstructorTests(TestCase): self.permission.has_permission(post_request, None) -@attr(shard=2) @ddt.ddt class IsStaffOrOwnerTests(TestCase): """ Tests for IsStaffOrOwner permission class. """ + shard = 2 def setUp(self): super(IsStaffOrOwnerTests, self).setUp() diff --git a/openedx/core/lib/gating/tests/test_api.py b/openedx/core/lib/gating/tests/test_api.py index d0341e9a58..ac80dd34c5 100644 --- a/openedx/core/lib/gating/tests/test_api.py +++ b/openedx/core/lib/gating/tests/test_api.py @@ -4,7 +4,6 @@ Tests for the gating API import unittest from mock import patch, Mock -from nose.plugins.attrib import attr from ddt import ddt, data, unpack from django.conf import settings from lms.djangoapps.gating import api as lms_gating_api @@ -17,12 +16,12 @@ from openedx.core.lib.gating.exceptions import GatingValidationError from student.tests.factories import UserFactory -@attr(shard=2) @ddt class TestGatingApi(ModuleStoreTestCase, MilestonesTestCaseMixin): """ Tests for the gating API """ + shard = 2 MODULESTORE = TEST_DATA_SPLIT_MODULESTORE diff --git a/openedx/core/lib/tests/test_course_tab_api.py b/openedx/core/lib/tests/test_course_tab_api.py index 18607aec71..57fa9d9a5c 100644 --- a/openedx/core/lib/tests/test_course_tab_api.py +++ b/openedx/core/lib/tests/test_course_tab_api.py @@ -3,17 +3,16 @@ Tests for the plugin API """ from django.test import TestCase -from nose.plugins.attrib import attr from openedx.core.lib.plugins import PluginError from openedx.core.lib.course_tabs import CourseTabPluginManager -@attr(shard=2) class TestCourseTabApi(TestCase): """ Unit tests for the course tab plugin API """ + shard = 2 def test_get_plugin(self): """ diff --git a/openedx/core/lib/tests/test_course_tabs.py b/openedx/core/lib/tests/test_course_tabs.py index 13484f60da..7c69f24b44 100644 --- a/openedx/core/lib/tests/test_course_tabs.py +++ b/openedx/core/lib/tests/test_course_tabs.py @@ -3,15 +3,14 @@ from unittest import TestCase from mock import Mock, patch -from nose.plugins.attrib import attr import xmodule.tabs as xmodule_tabs from openedx.core.lib.course_tabs import CourseTabPluginManager -@attr(shard=2) class CourseTabPluginManagerTestCase(TestCase): """Test cases for CourseTabPluginManager class""" + shard = 2 @patch('openedx.core.lib.course_tabs.CourseTabPluginManager.get_available_plugins') def test_get_tab_types(self, get_available_plugins): @@ -39,9 +38,9 @@ class CourseTabPluginManagerTestCase(TestCase): ) -@attr(shard=2) class KeyCheckerTestCase(TestCase): """Test cases for KeyChecker class""" + shard = 2 def setUp(self): super(KeyCheckerTestCase, self).setUp() @@ -58,9 +57,9 @@ class KeyCheckerTestCase(TestCase): xmodule_tabs.key_checker(self.invalid_keys)(self.dict_value) -@attr(shard=2) class NeedNameTestCase(TestCase): """Test cases for NeedName validator""" + shard = 2 def setUp(self): super(NeedNameTestCase, self).setUp() diff --git a/openedx/core/lib/tests/test_courses.py b/openedx/core/lib/tests/test_courses.py index 29519de99d..b3f06936a2 100644 --- a/openedx/core/lib/tests/test_courses.py +++ b/openedx/core/lib/tests/test_courses.py @@ -4,7 +4,6 @@ Tests for functionality in openedx/core/lib/courses.py. import ddt from django.test.utils import override_settings -from nose.plugins.attrib import attr from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase @@ -13,10 +12,10 @@ from xmodule.modulestore.tests.factories import CourseFactory from ..courses import course_image_url -@attr(shard=2) @ddt.ddt class CourseImageTestCase(ModuleStoreTestCase): """Tests for course image URLs.""" + shard = 2 def verify_url(self, expected_url, actual_url): """ diff --git a/openedx/core/lib/tests/test_edx_api_utils.py b/openedx/core/lib/tests/test_edx_api_utils.py index c70d6a8429..82ba8b77b7 100644 --- a/openedx/core/lib/tests/test_edx_api_utils.py +++ b/openedx/core/lib/tests/test_edx_api_utils.py @@ -5,7 +5,6 @@ import json import httpretty import mock from django.core.cache import cache -from nose.plugins.attrib import attr from openedx.core.djangoapps.catalog.models import CatalogIntegration from openedx.core.djangoapps.catalog.tests.mixins import CatalogIntegrationMixin @@ -20,11 +19,11 @@ TEST_API_URL = 'http://www-internal.example.com/api' @skip_unless_lms -@attr(shard=2) @httpretty.activate class TestGetEdxApiData(CatalogIntegrationMixin, CredentialsApiConfigMixin, CacheIsolationTestCase): """Tests for edX API data retrieval utility.""" ENABLED_CACHES = ['default'] + shard = 2 def setUp(self): super(TestGetEdxApiData, self).setUp() diff --git a/openedx/core/lib/tests/test_graph_traversals.py b/openedx/core/lib/tests/test_graph_traversals.py index cc1d164214..5cdcbf00c2 100644 --- a/openedx/core/lib/tests/test_graph_traversals.py +++ b/openedx/core/lib/tests/test_graph_traversals.py @@ -5,16 +5,14 @@ Tests for graph traversal generator functions. from collections import defaultdict from unittest import TestCase -from nose.plugins.attrib import attr - from ..graph_traversals import traverse_post_order, traverse_pre_order, traverse_topologically -@attr(shard=2) class TestGraphTraversals(TestCase): """ Test Class for graph traversal generator functions. """ + shard = 2 def setUp(self): # Creates a test graph with the following disconnected diff --git a/openedx/core/lib/tests/test_token_utils.py b/openedx/core/lib/tests/test_token_utils.py index 10ed16a641..a46ebe5700 100644 --- a/openedx/core/lib/tests/test_token_utils.py +++ b/openedx/core/lib/tests/test_token_utils.py @@ -2,14 +2,12 @@ import ddt import jwt from django.test import TestCase -from nose.plugins.attrib import attr from openedx.core.djangoapps.oauth_dispatch.tests import mixins from openedx.core.lib.token_utils import JwtBuilder from student.tests.factories import UserFactory, UserProfileFactory -@attr(shard=2) @ddt.ddt class TestJwtBuilder(mixins.AccessTokenMixin, TestCase): """ @@ -17,6 +15,7 @@ class TestJwtBuilder(mixins.AccessTokenMixin, TestCase): """ expires_in = 10 + shard = 2 def setUp(self): super(TestJwtBuilder, self).setUp() diff --git a/openedx/core/lib/tests/test_xblock_utils.py b/openedx/core/lib/tests/test_xblock_utils.py index 050a5fde17..837575c15e 100644 --- a/openedx/core/lib/tests/test_xblock_utils.py +++ b/openedx/core/lib/tests/test_xblock_utils.py @@ -7,7 +7,6 @@ import uuid import ddt from django.test.client import RequestFactory -from nose.plugins.attrib import attr from web_fragments.fragment import Fragment from openedx.core.lib.url_utils import quote_slashes @@ -26,12 +25,12 @@ from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -@attr(shard=2) @ddt.ddt class TestXblockUtils(SharedModuleStoreTestCase): """ Tests for xblock utility functions. """ + shard = 2 @classmethod def setUpClass(cls): diff --git a/openedx/core/lib/xblock_builtin/xblock_discussion/tests.py b/openedx/core/lib/xblock_builtin/xblock_discussion/tests.py index 4640109df2..77cfed238d 100644 --- a/openedx/core/lib/xblock_builtin/xblock_discussion/tests.py +++ b/openedx/core/lib/xblock_builtin/xblock_discussion/tests.py @@ -3,7 +3,6 @@ from collections import namedtuple import ddt import itertools import mock -from nose.plugins.attrib import attr import random import string from unittest import TestCase @@ -53,13 +52,13 @@ def _make_attribute_test_cases(): ) -@attr('shard2') @ddt.ddt class DiscussionXBlockImportExportTests(TestCase): """ Import and export tests """ DISCUSSION_XBLOCK_LOCATION = "openedx.core.lib.xblock_builtin.xblock_discussion.xblock_discussion.DiscussionXBlock" + shard = 2 def setUp(self): """ diff --git a/openedx/features/journals/tests/test_marketing_views.py b/openedx/features/journals/tests/test_marketing_views.py index 17b8aaf83c..1dd174aff0 100644 --- a/openedx/features/journals/tests/test_marketing_views.py +++ b/openedx/features/journals/tests/test_marketing_views.py @@ -2,7 +2,6 @@ import uuid import mock -from nose.plugins.attrib import attr from django.conf import settings from django.core.urlresolvers import reverse @@ -60,12 +59,12 @@ class JournalBundleViewTest(CacheIsolationTestCase, SiteMixin): self.assertContains(response, journal_bundle["courses"][0]["course_runs"][0]["title"]) -@attr(shard=1) @mock.patch.dict(settings.FEATURES, {"JOURNALS_ENABLED": True}) class JournalIndexViewTest(SiteMixin, ModuleStoreTestCase): """ Tests for Journals Listing in Marketing Pages. """ + shard = 1 def setUp(self): super(JournalIndexViewTest, self).setUp() diff --git a/openedx/tests/xblock_integration/test_crowdsource_hinter.py b/openedx/tests/xblock_integration/test_crowdsource_hinter.py index db6f303059..4c4ad6f5ed 100644 --- a/openedx/tests/xblock_integration/test_crowdsource_hinter.py +++ b/openedx/tests/xblock_integration/test_crowdsource_hinter.py @@ -6,7 +6,6 @@ import unittest from django.conf import settings from django.urls import reverse -from nose.plugins.attrib import attr from six import text_type from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory @@ -134,13 +133,14 @@ class TestCrowdsourceHinter(SharedModuleStoreTestCase, LoginEnrollmentTestCase): self.assert_request_status_code(200, self.course_url) -@attr(shard=6) class TestHinterFunctions(TestCrowdsourceHinter): """ Check that the essential functions of the hinter work as expected. Tests cover the basic process of receiving a hint, adding a new hint, and rating/reporting hints. """ + shard = 6 + def test_get_hint_with_no_hints(self): """ Check that a generic statement is returned when no default/specific hints exist diff --git a/openedx/tests/xblock_integration/test_recommender.py b/openedx/tests/xblock_integration/test_recommender.py index a5cd83244d..2b64a4fcef 100644 --- a/openedx/tests/xblock_integration/test_recommender.py +++ b/openedx/tests/xblock_integration/test_recommender.py @@ -15,8 +15,8 @@ from django.urls import reverse from ddt import data, ddt from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase -from nose.plugins.attrib import attr from six import text_type +from openedx.core.lib.tests import attr from openedx.core.lib.url_utils import quote_slashes from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory diff --git a/openedx/tests/xblock_integration/test_review_xblock.py b/openedx/tests/xblock_integration/test_review_xblock.py index 14eab4feef..4e9c7366f1 100644 --- a/openedx/tests/xblock_integration/test_review_xblock.py +++ b/openedx/tests/xblock_integration/test_review_xblock.py @@ -7,7 +7,6 @@ import unittest from django.conf import settings from django.contrib.auth.models import User from django.urls import reverse -from nose.plugins.attrib import attr from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase @@ -191,7 +190,6 @@ class TestReviewXBlock(SharedModuleStoreTestCase, LoginEnrollmentTestCase): self.enroll(course, verify=True) -@attr(shard=6) @ddt.ddt class TestReviewFunctions(TestReviewXBlock): """ @@ -199,6 +197,8 @@ class TestReviewFunctions(TestReviewXBlock): Tests cover the basic process of receiving a hint, adding a new hint, and rating/reporting hints. """ + shard = 6 + def test_no_review_problems(self): """ If a user has not seen any problems, they should diff --git a/scripts/thresholds.sh b/scripts/thresholds.sh index de0bf9955a..3733daa908 100755 --- a/scripts/thresholds.sh +++ b/scripts/thresholds.sh @@ -2,6 +2,6 @@ set -e export LOWER_PYLINT_THRESHOLD=1000 -export UPPER_PYLINT_THRESHOLD=3875 +export UPPER_PYLINT_THRESHOLD=3825 export ESLINT_THRESHOLD=5590 export STYLELINT_THRESHOLD=973