Skip to content

Commit

Permalink
rebalance python unittests onto new shards
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart Young committed May 3, 2018
1 parent 2556864 commit 1fd2167
Show file tree
Hide file tree
Showing 244 changed files with 862 additions and 129 deletions.
13 changes: 13 additions & 0 deletions cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class ImportRequiredTestCases(ContentStoreTestCase):
"""
Tests which legitimately need to import a course
"""
shard = 1

def test_no_static_link_rewrites_on_import(self):
course_items = import_course_from_xml(
self.store, self.user.id, TEST_DATA_DIR, ['toy'], create_if_not_present=True
Expand Down Expand Up @@ -609,6 +611,8 @@ class MiscCourseTests(ContentStoreTestCase):
"""
Tests that rely on the toy courses.
"""
shard = 1

def setUp(self):
super(MiscCourseTests, self).setUp()
# save locs not items b/c the items won't have the subsequently created children in them until refetched
Expand Down Expand Up @@ -1157,6 +1161,7 @@ class ContentStoreTest(ContentStoreTestCase):
"""
Tests for the CMS ContentStore application.
"""
shard = 1
duplicate_course_error = ("There is already a course defined with the same organization and course number. "
"Please change either organization or course number to be unique.")

Expand Down Expand Up @@ -1805,6 +1810,7 @@ def test_course_handler_with_invalid_course_key_string(self):

class MetadataSaveTestCase(ContentStoreTestCase):
"""Test that metadata is correctly cached and decached."""
shard = 1

def setUp(self):
super(MetadataSaveTestCase, self).setUp()
Expand Down Expand Up @@ -1866,6 +1872,8 @@ class RerunCourseTest(ContentStoreTestCase):
"""
Tests for Rerunning a course via the view handler
"""
shard = 1

def setUp(self):
super(RerunCourseTest, self).setUp()
self.destination_course_data = {
Expand Down Expand Up @@ -2108,6 +2116,8 @@ class ContentLicenseTest(ContentStoreTestCase):
"""
Tests around content licenses
"""
shard = 1

def test_course_license_export(self):
content_store = contentstore()
root_dir = path(mkdtemp_clean())
Expand Down Expand Up @@ -2146,6 +2156,8 @@ class EntryPageTestCase(TestCase):
"""
Tests entry pages that aren't specific to a course.
"""
shard = 1

def setUp(self):
super(EntryPageTestCase, self).setUp()
self.client = AjaxEnabledTestClient()
Expand Down Expand Up @@ -2180,6 +2192,7 @@ class SigninPageTestCase(TestCase):
important to make sure that the script is functional independently of any
other script.
"""
shard = 1

def test_csrf_token_is_present_in_form(self):
# Expected html:
Expand Down
12 changes: 12 additions & 0 deletions cms/djangoapps/contentstore/tests/test_course_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class CourseSettingsEncoderTest(CourseTestCase):
"""
Tests for CourseSettingsEncoder.
"""
shard = 1

def test_encoder(self):
details = CourseDetails.fetch(self.course.id)
jsondetails = json.dumps(details, cls=CourseSettingsEncoder)
Expand Down Expand Up @@ -87,6 +89,8 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin):
"""
Tests for modifying content on the first course settings page (course dates, overview, etc.).
"""
shard = 1

def alter_field(self, url, details, field, val):
"""
Change the one field to the given value and then invoke the update post to see if it worked.
Expand Down Expand Up @@ -435,6 +439,8 @@ class CourseGradingTest(CourseTestCase):
"""
Tests for the course settings grading page.
"""
shard = 1

def test_initial_grader(self):
test_grader = CourseGradingModel(self.course)
self.assertIsNotNone(test_grader.graders)
Expand Down Expand Up @@ -769,6 +775,8 @@ class CourseMetadataEditingTest(CourseTestCase):
"""
Tests for CourseMetadata.
"""
shard = 1

def setUp(self):
CourseTestCase.setUp(self)
self.fullcourse = CourseFactory.create()
Expand Down Expand Up @@ -1158,6 +1166,8 @@ class CourseGraderUpdatesTest(CourseTestCase):
"""
Test getting, deleting, adding, & updating graders
"""
shard = 1

def setUp(self):
"""Compute the url to use in tests"""
super(CourseGraderUpdatesTest, self).setUp()
Expand Down Expand Up @@ -1223,6 +1233,8 @@ class CourseEnrollmentEndFieldTest(CourseTestCase):
Base class to test the enrollment end fields in the course settings details view in Studio
when using marketing site flag and global vs non-global staff to access the page.
"""
shard = 1

NOT_EDITABLE_HELPER_MESSAGE = "Contact your edX partner manager to update these settings."
NOT_EDITABLE_DATE_WRAPPER = "<div class=\"field date is-not-editable\" id=\"field-enrollment-end-date\">"
NOT_EDITABLE_TIME_WRAPPER = "<div class=\"field time is-not-editable\" id=\"field-enrollment-end-time\">"
Expand Down
6 changes: 6 additions & 0 deletions cms/djangoapps/contentstore/tests/test_courseware_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def update_item(self, store, item):
@ddt.ddt
class TestCoursewareSearchIndexer(MixedWithOptionsTestCase):
""" Tests the operation of the CoursewareSearchIndexer """
shard = 1

WORKS_WITH_STORES = (ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)

Expand Down Expand Up @@ -605,6 +606,7 @@ def test_delete_course_from_search_index_after_course_deletion(self, store_type)
@ddt.ddt
class TestLargeCourseDeletions(MixedWithOptionsTestCase):
""" Tests to excerise deleting items from a course """
shard = 1

WORKS_WITH_STORES = (ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)

Expand Down Expand Up @@ -688,6 +690,7 @@ class TestTaskExecution(SharedModuleStoreTestCase):
being present, which allows us to ensure that when the listener is
executed, it is done as expected.
"""
shard = 1

@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -782,6 +785,7 @@ def test_task_library_update(self):
@ddt.ddt
class TestLibrarySearchIndexer(MixedWithOptionsTestCase):
""" Tests the operation of the CoursewareSearchIndexer """
shard = 1

# libraries work only with split, so do library indexer
WORKS_WITH_STORES = (ModuleStoreEnum.Type.split, )
Expand Down Expand Up @@ -955,6 +959,8 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase):
"""
Tests indexing of content groups on course modules using mongo modulestore.
"""
shard = 1

MODULESTORE = TEST_DATA_MONGO_MODULESTORE
INDEX_NAME = CoursewareSearchIndexer.INDEX_NAME

Expand Down
10 changes: 10 additions & 0 deletions cms/djangoapps/contentstore/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class LibraryTestCase(ModuleStoreTestCase):
"""
Common functionality for content libraries tests
"""
shard = 1

def setUp(self):
super(LibraryTestCase, self).setUp()

Expand Down Expand Up @@ -148,6 +150,8 @@ class TestLibraries(LibraryTestCase):
"""
High-level tests for libraries
"""
shard = 1

@ddt.data(
(2, 1, 1),
(2, 2, 2),
Expand Down Expand Up @@ -480,6 +484,8 @@ class TestLibraryAccess(SignalDisconnectTestMixin, LibraryTestCase):
"""
Test Roles and Permissions related to Content Libraries
"""
shard = 1

def setUp(self):
""" Create a library, staff user, and non-staff user """
super(TestLibraryAccess, self).setUp()
Expand Down Expand Up @@ -813,6 +819,8 @@ class TestOverrides(LibraryTestCase):
"""
Test that overriding block Scope.settings fields from a library in a specific course works
"""
shard = 1

def setUp(self):
super(TestOverrides, self).setUp()
self.original_display_name = "A Problem Block"
Expand Down Expand Up @@ -997,6 +1005,8 @@ class TestIncompatibleModuleStore(LibraryTestCase):
"""
Tests for proper validation errors with an incompatible course modulestore.
"""
shard = 1

def setUp(self):
super(TestIncompatibleModuleStore, self).setUp()
# Create a course in an incompatible modulestore.
Expand Down
4 changes: 4 additions & 0 deletions cms/djangoapps/contentstore/views/tests/test_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class CertificatesBaseTestCase(object):
"""
Mixin with base test cases for the certificates.
"""
shard = 1

def _remove_ids(self, content):
"""
Expand Down Expand Up @@ -199,6 +200,8 @@ class CertificatesListHandlerTestCase(
"""
Test cases for certificates_list_handler.
"""
shard = 1

def setUp(self):
"""
Set up CertificatesListHandlerTestCase.
Expand Down Expand Up @@ -425,6 +428,7 @@ class CertificatesDetailHandlerTestCase(
"""
Test cases for CertificatesDetailHandlerTestCase.
"""
shard = 1

_id = 0

Expand Down
6 changes: 6 additions & 0 deletions cms/djangoapps/contentstore/views/tests/test_course_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class TestCourseIndex(CourseTestCase):
"""
Unit tests for getting the list of courses and the course outline.
"""
shard = 1

def setUp(self):
"""
Add a course with odd characters in the fields
Expand Down Expand Up @@ -315,6 +317,8 @@ class TestCourseIndexArchived(CourseTestCase):
"""
Unit tests for testing the course index list when there are archived courses.
"""
shard = 1

NOW = datetime.datetime.now(pytz.utc)
DAY = datetime.timedelta(days=1)
YESTERDAY = NOW - DAY
Expand Down Expand Up @@ -426,6 +430,7 @@ class TestCourseOutline(CourseTestCase):
"""
Unit tests for the course outline.
"""
shard = 1
ENABLED_SIGNALS = ['course_published']

def setUp(self):
Expand Down Expand Up @@ -633,6 +638,7 @@ class TestCourseReIndex(CourseTestCase):
"""
Unit tests for the course outline.
"""
shard = 1
SUCCESSFUL_RESPONSE = _("Course has been successfully reindexed.")

ENABLED_SIGNALS = ['course_published']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class GroupConfigurationsBaseTestCase(object):
"""
Mixin with base test cases for the group configurations.
"""
shard = 1

def _remove_ids(self, content):
"""
Remove ids from the response. We cannot predict IDs, because they're
Expand Down Expand Up @@ -240,6 +242,8 @@ class GroupConfigurationsListHandlerTestCase(CourseTestCase, GroupConfigurations
"""
Test cases for group_configurations_list_handler.
"""
shard = 1

def _url(self):
"""
Return url for the handler.
Expand Down Expand Up @@ -331,6 +335,7 @@ class GroupConfigurationsDetailHandlerTestCase(CourseTestCase, GroupConfiguratio
Test cases for group_configurations_detail_handler.
"""

shard = 1
ID = 0

def _url(self, cid=-1):
Expand Down Expand Up @@ -634,6 +639,8 @@ class GroupConfigurationsUsageInfoTestCase(CourseTestCase, HelperMethods):
"""
Tests for usage information of configurations and content groups.
"""
shard = 1

def _get_user_partition(self, scheme):
"""
Returns the first user partition with the specified scheme.
Expand Down Expand Up @@ -1066,6 +1073,8 @@ class GroupConfigurationsValidationTestCase(CourseTestCase, HelperMethods):
"""
Tests for validation in Group Configurations.
"""
shard = 1

@patch('xmodule.split_test_module.SplitTestDescriptor.validate_split_test')
def verify_validation_add_usage_info(self, expected_result, mocked_message, mocked_validation_messages):
"""
Expand Down
Loading

0 comments on commit 1fd2167

Please sign in to comment.