Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ def test_no_static_link_rewrites_on_import(self):
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'<?xml version="1.0"?>\n<table_of_contents>\n <entry page="5" page_label="ii" name="Table of Contents"/></table_of_contents>\n'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more style nitpick: this line is too long.

Try something like this:

 # At the top of the file
 from textwrap import dedent

# When setting the return value...
dedent("""
    XML string...
    goes here.
""").strip()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed


module_store = modulestore('direct')
import_from_xml(module_store, 'common/test/data/', ['toy'])

Expand Down Expand Up @@ -845,7 +848,10 @@ def verify_content_existence(self, store, root_dir, location, dirname, category_
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'<?xml version="1.0"?>\n<table_of_contents>\n <entry page="5" page_label="ii" name="Table of Contents"/></table_of_contents>\n'

module_store = modulestore('direct')
draft_store = modulestore('draft')
content_store = contentstore()
Expand Down
5 changes: 4 additions & 1 deletion lms/djangoapps/courseware/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Test for lms courseware app
'''
import random
import mock

from django.test import TestCase
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -162,7 +163,9 @@ def test_toy_course_loads(self):
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'<?xml version="1.0"?>\n<table_of_contents>\n <entry page="5" page_label="ii" name="Table of Contents"/></table_of_contents>\n'
module_store = modulestore()
import_from_xml(module_store, TEST_DATA_DIR, ['toy'])

Expand Down