From 11ef3961bcc380e23234d05a66e1abaead4be7c0 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Tue, 2 Jul 2013 11:06:45 -0400 Subject: [PATCH] try to add some additional diff coverage which should get us to 100% --- .../contentstore/tests/test_contentstore.py | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index e369c9bc45..ef5da56299 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -344,8 +344,8 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): err_cnt = perform_xlint('common/test/data', ['full']) self.assertGreater(err_cnt, 0) - @override_settings(COURSES_WITH_UNSAFE_CODE=['edx/full/.*']) - def test_module_preview(self): + @override_settings(COURSES_WITH_UNSAFE_CODE=['edX/full/.*']) + def test_module_preview_in_whitelist(self): ''' Tests the ajax callback to render an XModule ''' @@ -366,6 +366,25 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): resp = self.client.get(url) self.assertEqual(resp.status_code, 200) + @override_settings(COURSES_WITH_UNSAFE_CODE=['edX/dummycourse/.*']) + def test_module_preview_not_in_whitelist(self): + ''' + Tests the ajax callback to render an XModule problem but we don't have the course listed in + our whitelist. + ''' + direct_store = modulestore('direct') + import_from_xml(direct_store, 'common/test/data/', ['full']) + + html_module_location = Location(['i4x', 'edX', 'full', 'html', 'html_90', None]) + + url = reverse('preview_component', kwargs={'location': html_module_location.url()}) + + # also try a custom response which will trigger the 'is this course in whitelist' logic + problem_module_location = Location(['i4x', 'edX', 'full', 'problem', 'H1P1_Energy', None]) + url = reverse('preview_component', kwargs={'location': problem_module_location.url()}) + resp = self.client.get(url) + self.assertEqual(resp.status_code, 200) + def test_delete(self): direct_store = modulestore('direct') import_from_xml(direct_store, 'common/test/data/', ['full'])