From 1759191370c2a3871ed91e0bc67e59558c7d6699 Mon Sep 17 00:00:00 2001 From: lapentab Date: Thu, 22 Aug 2013 08:43:28 -0400 Subject: [PATCH] Remove network calls in tests --- cms/djangoapps/contentstore/tests/test_contentstore.py | 10 ++++++++-- lms/djangoapps/courseware/tests/tests.py | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 7491e5ab4a..f13edbd213 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -312,7 +312,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): handouts = module_store.get_item(Location(['i4x', 'edX', 'toy', 'html', 'toyhtml', None])) self.assertIn('/static/', handouts.data) - def test_import_textbook_as_content_element(self): + @mock.patch('xmodule.course_module.requests.get') + def test_import_textbook_as_content_element(self, mock_get): + mock_get.return_value.text = u'\n\n \n' + module_store = modulestore('direct') import_from_xml(module_store, 'common/test/data/', ['toy']) @@ -845,7 +848,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): filesystem = OSFS(root_dir / ('test_export/' + dirname)) self.assertTrue(filesystem.exists(item.location.name + filename_suffix)) - def test_export_course(self): + @mock.patch('xmodule.course_module.requests.get') + def test_export_course(self, mock_get): + mock_get.return_value.text = u'\n\n \n' + module_store = modulestore('direct') draft_store = modulestore('draft') content_store = contentstore() diff --git a/lms/djangoapps/courseware/tests/tests.py b/lms/djangoapps/courseware/tests/tests.py index 68b06a1ba8..5cf84d7088 100644 --- a/lms/djangoapps/courseware/tests/tests.py +++ b/lms/djangoapps/courseware/tests/tests.py @@ -2,6 +2,7 @@ Test for lms courseware app ''' import random +import mock from django.test import TestCase from django.core.urlresolvers import reverse @@ -162,7 +163,9 @@ class TestCoursesLoadTestCase_MongoModulestore(PageLoaderTestCase): import_from_xml(module_store, TEST_DATA_DIR, ['toy']) self.check_random_page_loads(module_store) - def test_toy_textbooks_loads(self): + @mock.patch('xmodule.course_module.requests.get') + def test_toy_textbooks_loads(self, mock_get): + mock_get.return_value.text = u'\n\n \n' module_store = modulestore() import_from_xml(module_store, TEST_DATA_DIR, ['toy'])