diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py b/common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py index 6763838fde..23a8c21f6b 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py @@ -16,8 +16,7 @@ import ddt import itertools import random from contextlib import contextmanager, nested -from functools import partial -from unittest import TestCase +from unittest import SkipTest from shutil import rmtree from tempfile import mkdtemp from opaque_keys.edx.locations import SlashSeparatedCourseKey @@ -46,9 +45,23 @@ class MemoryCache(object): self._data = {} def get(self, key, default=None): + """ + Get a key from the cache. + + Args: + key: The key to update. + default: The value to return if the key hasn't been set previously. + """ return self._data.get(key, default) def set(self, key, value): + """ + Set a key in the cache. + + Args: + key: The key to update. + value: The value change the key to. + """ self._data[key] = value @@ -113,6 +126,8 @@ class VersioningModulestoreBuilder(object): contentstore: The contentstore that this modulestore should use to store all of its assets. """ + # pylint: disable=unreachable + raise SkipTest("DraftVersioningModuleStore doesn't yet support the same interface as the rest of the modulestores") doc_store_config = dict( db='modulestore{}'.format(random.randint(0, 10000)), collection='split_module', @@ -142,6 +157,7 @@ class VersioningModulestoreBuilder(object): def __repr__(self): return 'SplitModulestoreBuilder()' + class MixedModulestoreBuilder(object): """ A builder class for a MixedModuleStore. @@ -221,6 +237,7 @@ MODULESTORE_SETUPS = ( CONTENTSTORE_SETUPS = (MongoContentstoreBuilder(),) COURSE_DATA_NAMES = ('toy', 'test_unicode') + @ddt.ddt class CrossStoreXMLRoundtrip(CourseComparisonTest): """ @@ -242,7 +259,6 @@ class CrossStoreXMLRoundtrip(CourseComparisonTest): )) @ddt.unpack def test_round_trip(self, source_builder, dest_builder, source_content_builder, dest_content_builder, course_data_name): - self.maxDiff = None source_course_key = SlashSeparatedCourseKey('source', 'course', 'key') dest_course_key = SlashSeparatedCourseKey('dest', 'course', 'key') diff --git a/common/lib/xmodule/xmodule/tests/__init__.py b/common/lib/xmodule/xmodule/tests/__init__.py index e7c8e06912..eaedb54da7 100644 --- a/common/lib/xmodule/xmodule/tests/__init__.py +++ b/common/lib/xmodule/xmodule/tests/__init__.py @@ -176,6 +176,12 @@ class CourseComparisonTest(unittest.TestCase): self.field_exclusions.add((usage_id, field_name)) def ignore_asset_key(self, key_name): + """ + Add an asset key to the list of keys to be ignored when comparing assets. + + Args: + key_name: The name of the key to ignore. + """ self.ignored_asset_keys.add(key_name) def assertCoursesEqual(self, expected_store, expected_course_key, actual_store, actual_course_key): @@ -253,6 +259,9 @@ class CourseComparisonTest(unittest.TestCase): self.assertEqual(expected_children, actual_item.children) def assertAssetEqual(self, expected_course_key, expected_asset, actual_course_key, actual_asset): + """ + Assert that two assets are equal, allowing for differences related to their being from different courses. + """ for key in self.ignored_asset_keys: if key in expected_asset: del expected_asset[key] @@ -270,7 +279,10 @@ class CourseComparisonTest(unittest.TestCase): self.assertEqual(actual_key.to_deprecated_string(), actual_filename) self.assertEqual(expected_asset, actual_asset) - def _assertAssetsEqual(self, expected_course_key, expected_assets, actual_course_key, actual_assets): + def _assertAssetsEqual(self, expected_course_key, expected_assets, actual_course_key, actual_assets): # pylint: disable=invalid-name + """ + Private helper method for assertAssetsEqual + """ self.assertEqual(len(expected_assets), len(actual_assets)) actual_assets_map = {asset['asset_key']: asset for asset in actual_assets}