From e66cb05c03e093a2bc08f16a12f9d5389439d023 Mon Sep 17 00:00:00 2001 From: John Eskew Date: Thu, 4 Dec 2014 09:42:22 -0500 Subject: [PATCH] Return empty values and log a warning instead of raising NotImplemented exceptions for XML modulestore asset metadata methods. --- common/lib/xmodule/xmodule/modulestore/__init__.py | 3 ++- .../xmodule/modulestore/tests/test_assetstore.py | 12 ++++-------- common/lib/xmodule/xmodule/modulestore/xml.py | 9 ++++++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index 085f3f7d5e..e149d47bd3 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -285,7 +285,8 @@ class ModuleStoreAssetInterface(object): Returns the container holding a dict indexed by asset block_type whose values are a list of raw metadata documents """ - raise NotImplementedError() + log.warning("_find_course_assets request of ModuleStoreAssetInterface - not implemented.") + return None def _find_course_asset(self, asset_key): """ diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_assetstore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_assetstore.py index 87a9c5d7c5..2a8e6fd064 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_assetstore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_assetstore.py @@ -455,14 +455,10 @@ class TestMongoAssetMetadataStorage(unittest.TestCase): with storebuilder.build(None) as store: course_key = store.make_course_key("org", "course", "run") asset_key = course_key.make_asset_key('asset', 'foo.jpg') - for method in ['find_asset_metadata']: - with self.assertRaises(NotImplementedError): - getattr(store, method)(asset_key) - with self.assertRaises(NotImplementedError): - # pylint: disable=protected-access - store._find_course_asset(asset_key) - with self.assertRaises(NotImplementedError): - store.get_all_asset_metadata(course_key, 'asset') + self.assertEquals(store.find_asset_metadata(asset_key), None) + # pylint: disable=protected-access + self.assertEquals(store._find_course_asset(asset_key), (None, None)) + self.assertEquals(store.get_all_asset_metadata(course_key, 'asset'), []) @ddt.data(*MODULESTORE_SETUPS) def test_copy_all_assets_same_modulestore(self, storebuilder): diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index e6a0ca15c3..0007d57574 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -867,18 +867,21 @@ class XMLModuleStore(ModuleStoreReadBase): For now this is not implemented, but others should feel free to implement using the asset.json which export produces. """ - raise NotImplementedError() + log.warning("_find_course_asset request of XML modulestore - not implemented.") + return (None, None) def find_asset_metadata(self, asset_key, **kwargs): """ For now this is not implemented, but others should feel free to implement using the asset.json which export produces. """ - raise NotImplementedError() + log.warning("find_asset_metadata request of XML modulestore - not implemented.") + return None def get_all_asset_metadata(self, course_key, asset_type, start=0, maxresults=-1, sort=None, **kwargs): """ For now this is not implemented, but others should feel free to implement using the asset.json which export produces. """ - raise NotImplementedError() + log.warning("get_all_asset_metadata request of XML modulestore - not implemented.") + return []