From d88b0c488e7f9d54d9e0d5d277773d6738fcaddf Mon Sep 17 00:00:00 2001 From: cahrens Date: Fri, 6 Feb 2015 17:22:47 -0500 Subject: [PATCH] store.has_course fails on old mongo with unicode chars. xml_importer now calls store.has_course even if create_course_if_not_present is False. --- .../contentstore/tests/test_import.py | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_import.py b/cms/djangoapps/contentstore/tests/test_import.py index 8a4006943b..01efcca80c 100644 --- a/cms/djangoapps/contentstore/tests/test_import.py +++ b/cms/djangoapps/contentstore/tests/test_import.py @@ -83,23 +83,24 @@ class ContentStoreImportTest(ModuleStoreTestCase): """ # Test that importing course with unicode 'id' and 'display name' doesn't give UnicodeEncodeError """ - module_store = modulestore() - course_id = module_store.make_course_key(u'Юникода', u'unicode_course', u'échantillon') - import_from_xml( - module_store, - self.user.id, - TEST_DATA_DIR, - ['2014_Uni'], - target_course_id=course_id, - # When this test is run with split modulestore as the default, the create course option must be specified. - # create_course_if_not_present=True - ) + # Test with the split modulestore because store.has_course fails in old mongo with unicode characters. + with modulestore().default_store(ModuleStoreEnum.Type.split): + module_store = modulestore() + course_id = module_store.make_course_key(u'Юникода', u'unicode_course', u'échantillon') + import_from_xml( + module_store, + self.user.id, + TEST_DATA_DIR, + ['2014_Uni'], + target_course_id=course_id, + create_course_if_not_present=True + ) - course = module_store.get_course(course_id) - self.assertIsNotNone(course) + course = module_store.get_course(course_id) + self.assertIsNotNone(course) - # test that course 'display_name' same as imported course 'display_name' - self.assertEqual(course.display_name, u"Φυσικά το όνομα Unicode") + # test that course 'display_name' same as imported course 'display_name' + self.assertEqual(course.display_name, u"Φυσικά το όνομα Unicode") def test_static_import(self): '''