diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_import.py b/cms/djangoapps/contentstore/management/commands/tests/test_import.py index da9e875719..f613c27875 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_import.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_import.py @@ -12,7 +12,6 @@ from django.core.management import call_command from django_comment_common.utils import are_permissions_roles_seeded from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from opaque_keys.edx.locations import SlashSeparatedCourseKey class TestImport(ModuleStoreTestCase): @@ -20,10 +19,6 @@ class TestImport(ModuleStoreTestCase): Unit tests for importing a course from command line """ - BASE_COURSE_KEY = SlashSeparatedCourseKey(u'edX', u'test_import_course', u'2013_Spring') - DIFF_KEY = SlashSeparatedCourseKey(u'edX', u'test_import_course', u'2014_Spring') - TRUNCATED_KEY = SlashSeparatedCourseKey(u'edX', u'test_import', u'2014_Spring') - def create_course_xml(self, content_dir, course_id): directory = tempfile.mkdtemp(dir=content_dir) os.makedirs(os.path.join(directory, "course")) @@ -44,38 +39,23 @@ class TestImport(ModuleStoreTestCase): self.content_dir = path(tempfile.mkdtemp()) self.addCleanup(shutil.rmtree, self.content_dir) - # Create good course xml - self.good_dir = self.create_course_xml(self.content_dir, self.BASE_COURSE_KEY) + self.base_course_key = self.store.make_course_key(u'edX', u'test_import_course', u'2013_Spring') + self.truncated_key = self.store.make_course_key(u'edX', u'test_import', u'2014_Spring') - # Create run changed course xml - self.dupe_dir = self.create_course_xml(self.content_dir, self.DIFF_KEY) + # Create good course xml + self.good_dir = self.create_course_xml(self.content_dir, self.base_course_key) # Create course XML where TRUNCATED_COURSE.org == BASE_COURSE_ID.org # and BASE_COURSE_ID.startswith(TRUNCATED_COURSE.course) - self.course_dir = self.create_course_xml(self.content_dir, self.TRUNCATED_KEY) + self.course_dir = self.create_course_xml(self.content_dir, self.truncated_key) def test_forum_seed(self): """ Tests that forum roles were created with import. """ - self.assertFalse(are_permissions_roles_seeded(self.BASE_COURSE_KEY)) + self.assertFalse(are_permissions_roles_seeded(self.base_course_key)) call_command('import', self.content_dir, self.good_dir) - self.assertTrue(are_permissions_roles_seeded(self.BASE_COURSE_KEY)) - - def test_duplicate_with_url(self): - """ - Check to make sure an import doesn't import courses that have the - same org and course, but they have different runs in order to - prevent modulestore "findone" exceptions on deletion - """ - # Load up base course and verify it is available - call_command('import', self.content_dir, self.good_dir) - store = modulestore() - self.assertIsNotNone(store.get_course(self.BASE_COURSE_KEY)) - - # Now load up duped course and verify it doesn't load - call_command('import', self.content_dir, self.dupe_dir) - self.assertIsNone(store.get_course(self.DIFF_KEY)) + self.assertTrue(are_permissions_roles_seeded(self.base_course_key)) def test_truncated_course_with_url(self): """ @@ -87,8 +67,8 @@ class TestImport(ModuleStoreTestCase): # Load up base course and verify it is available call_command('import', self.content_dir, self.good_dir) store = modulestore() - self.assertIsNotNone(store.get_course(self.BASE_COURSE_KEY)) + self.assertIsNotNone(store.get_course(self.base_course_key)) # Now load up the course with a similar course_id and verify it loads call_command('import', self.content_dir, self.course_dir) - self.assertIsNotNone(store.get_course(self.TRUNCATED_KEY)) + self.assertIsNotNone(store.get_course(self.truncated_key))