diff --git a/.gitignore b/.gitignore index 2fd1ca0181..493df5a7fd 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ lms/lib/comment_client/python nosetests.xml cover_html/ .idea/ +.redcar/ chromedriver.log \ No newline at end of file diff --git a/.redcar/lucene/segments.gen b/.redcar/lucene/segments.gen new file mode 100644 index 0000000000..568652b956 Binary files /dev/null and b/.redcar/lucene/segments.gen differ diff --git a/.redcar/lucene_last_updated b/.redcar/lucene_last_updated new file mode 100644 index 0000000000..3692c8e076 --- /dev/null +++ b/.redcar/lucene_last_updated @@ -0,0 +1 @@ +1360614836 diff --git a/.redcar/redcar.lock b/.redcar/redcar.lock new file mode 100644 index 0000000000..0677ede437 --- /dev/null +++ b/.redcar/redcar.lock @@ -0,0 +1 @@ +10664: Locked by 10664 at Mon Feb 11 14:22:22 -0500 2013 diff --git a/.redcar/storage/cursor_saver.yaml b/.redcar/storage/cursor_saver.yaml new file mode 100644 index 0000000000..ba9b833044 --- /dev/null +++ b/.redcar/storage/cursor_saver.yaml @@ -0,0 +1,4 @@ +--- +cursor_positions: [] + +files_to_retain: 0 diff --git a/.redcar/tags.REMOVED.git-id b/.redcar/tags.REMOVED.git-id new file mode 100644 index 0000000000..f8318e5f1f --- /dev/null +++ b/.redcar/tags.REMOVED.git-id @@ -0,0 +1 @@ +ce76efcea5f0a5b2238364f81d54f1d393853a1a \ No newline at end of file diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index b79d86b52f..66e6551019 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -5,7 +5,7 @@ from django.test.utils import override_settings from django.conf import settings from django.core.urlresolvers import reverse from path import path -from tempfile import mkdtemp +from tempdir import mkdtemp_clean import json from fs.osfs import OSFS import copy @@ -194,7 +194,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): import_from_xml(ms, 'common/test/data/', ['full']) location = CourseDescriptor.id_to_location('edX/full/6.002_Spring_2012') - root_dir = path(mkdtemp()) + root_dir = path(mkdtemp_clean()) print 'Exporting to tempdir = {0}'.format(root_dir) @@ -264,6 +264,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): self.assertContains(resp, '/c4x/edX/full/asset/handouts_schematic_tutorial.pdf') + class ContentStoreTest(ModuleStoreTestCase): """ Tests for the CMS ContentStore application. @@ -421,6 +422,64 @@ class ContentStoreTest(ModuleStoreTestCase): self.assertIn('markdown', problem.metadata, "markdown is missing from metadata") self.assertNotIn('markdown', problem.editable_metadata_fields, "Markdown slipped into the editable metadata fields") + def test_import_metadata_with_attempts_empty_string(self): + import_from_xml(modulestore(), 'common/test/data/', ['simple']) + ms = modulestore('direct') + did_load_item = False + try: + ms.get_item(Location(['i4x', 'edX', 'simple', 'problem', 'ps01-simple', None])) + did_load_item = True + except ItemNotFoundError: + pass + + # make sure we found the item (e.g. it didn't error while loading) + self.assertTrue(did_load_item) + + def test_metadata_inheritance(self): + import_from_xml(modulestore(), 'common/test/data/', ['full']) + + ms = modulestore('direct') + course = ms.get_item(Location(['i4x', 'edX', 'full', 'course', '6.002_Spring_2012', None])) + + verticals = ms.get_items(['i4x', 'edX', 'full', 'vertical', None, None]) + + # let's assert on the metadata_inheritance on an existing vertical + for vertical in verticals: + self.assertIn('xqa_key', vertical.metadata) + self.assertEqual(course.metadata['xqa_key'], vertical.metadata['xqa_key']) + + self.assertGreater(len(verticals), 0) + + new_component_location = Location('i4x', 'edX', 'full', 'html', 'new_component') + source_template_location = Location('i4x', 'edx', 'templates', 'html', 'Blank_HTML_Page') + + # crate a new module and add it as a child to a vertical + ms.clone_item(source_template_location, new_component_location) + parent = verticals[0] + ms.update_children(parent.location, parent.definition.get('children', []) + [new_component_location.url()]) + + # flush the cache + ms.get_cached_metadata_inheritance_tree(new_component_location, -1) + new_module = ms.get_item(new_component_location) + + # check for grace period definition which should be defined at the course level + self.assertIn('graceperiod', new_module.metadata) + + self.assertEqual(course.metadata['graceperiod'], new_module.metadata['graceperiod']) + + # + # now let's define an override at the leaf node level + # + new_module.metadata['graceperiod'] = '1 day' + ms.update_metadata(new_module.location, new_module.metadata) + + # flush the cache and refetch + ms.get_cached_metadata_inheritance_tree(new_component_location, -1) + new_module = ms.get_item(new_component_location) + + self.assertIn('graceperiod', new_module.metadata) + self.assertEqual('1 day', new_module.metadata['graceperiod']) + class TemplateTestCase(ModuleStoreTestCase): diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index 166982e35f..c4a46459e2 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -4,7 +4,6 @@ from django.test.client import Client from django.conf import settings from django.core.urlresolvers import reverse from path import path -from tempfile import mkdtemp import json from fs.osfs import OSFS import copy diff --git a/cms/djangoapps/contentstore/tests/utils.py b/cms/djangoapps/contentstore/tests/utils.py index be028b2836..b6b8cd5023 100644 --- a/cms/djangoapps/contentstore/tests/utils.py +++ b/cms/djangoapps/contentstore/tests/utils.py @@ -1,6 +1,6 @@ import json import copy -from time import time +from uuid import uuid4 from django.test import TestCase from django.conf import settings @@ -20,13 +20,12 @@ class ModuleStoreTestCase(TestCase): def _pre_setup(self): super(ModuleStoreTestCase, self)._pre_setup() - # Use the current seconds since epoch to differentiate + # Use a uuid to differentiate # the mongo collections on jenkins. - sec_since_epoch = '%s' % int(time() * 100) self.orig_MODULESTORE = copy.deepcopy(settings.MODULESTORE) self.test_MODULESTORE = self.orig_MODULESTORE - self.test_MODULESTORE['default']['OPTIONS']['collection'] = 'modulestore_%s' % sec_since_epoch - self.test_MODULESTORE['direct']['OPTIONS']['collection'] = 'modulestore_%s' % sec_since_epoch + self.test_MODULESTORE['default']['OPTIONS']['collection'] = 'modulestore_%s' % uuid4().hex + self.test_MODULESTORE['direct']['OPTIONS']['collection'] = 'modulestore_%s' % uuid4().hex settings.MODULESTORE = self.test_MODULESTORE # Flush and initialize the module store diff --git a/cms/envs/common.py b/cms/envs/common.py index 281dd97f20..50f237c374 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -20,7 +20,6 @@ Longer TODO: """ import sys -import tempfile import os.path import os import lms.envs.common @@ -59,7 +58,8 @@ sys.path.append(COMMON_ROOT / 'lib') ############################# WEB CONFIGURATION ############################# # This is where we stick our compiled template files. -MAKO_MODULE_DIR = tempfile.mkdtemp('mako') +from tempdir import mkdtemp_clean +MAKO_MODULE_DIR = mkdtemp_clean('mako') MAKO_TEMPLATES = {} MAKO_TEMPLATES['main'] = [ PROJECT_ROOT / 'templates', diff --git a/cms/static/js/models/settings/course_details.js b/cms/static/js/models/settings/course_details.js index 168cb960be..97d71f6c79 100644 --- a/cms/static/js/models/settings/course_details.js +++ b/cms/static/js/models/settings/course_details.js @@ -68,10 +68,10 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({ save_videosource: function(newsource) { // newsource either is