diff --git a/common/lib/xmodule/xmodule/tests/__init__.py b/common/lib/xmodule/xmodule/tests/__init__.py
index 2106c2fb78..d310110844 100644
--- a/common/lib/xmodule/xmodule/tests/__init__.py
+++ b/common/lib/xmodule/xmodule/tests/__init__.py
@@ -29,14 +29,14 @@ open_ended_grading_interface = {
}
-def system_test():
+def get_test_system():
"""
Construct a test ModuleSystem instance.
By default, the render_template() method simply returns the repr of the
context it is passed. You can override this behavior by monkey patching::
- system = system_test()
+ system = get_test_system()
system.render_template = my_render_func
where `my_render_func` is a function of the form my_render_func(template, context).
diff --git a/common/lib/xmodule/xmodule/tests/test_annotatable_module.py b/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
index 38993e7d8a..a7c73b0641 100644
--- a/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
+++ b/common/lib/xmodule/xmodule/tests/test_annotatable_module.py
@@ -8,7 +8,7 @@ from mock import Mock
from xmodule.annotatable_module import AnnotatableModule
from xmodule.modulestore import Location
-from . import system_test
+from . import get_test_system
class AnnotatableModuleTestCase(unittest.TestCase):
location = Location(["i4x", "edX", "toy", "annotatable", "guided_discussion"])
@@ -32,7 +32,7 @@ class AnnotatableModuleTestCase(unittest.TestCase):
module_data = {'data': sample_xml}
def setUp(self):
- self.annotatable = AnnotatableModule(system_test(), self.location, self.descriptor, self.module_data)
+ self.annotatable = AnnotatableModule(get_test_system(), self.location, self.descriptor, self.module_data)
def test_annotation_data_attr(self):
el = etree.fromstring('test')
diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py
index 44783a3736..67873cd66f 100644
--- a/common/lib/xmodule/xmodule/tests/test_capa_module.py
+++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py
@@ -17,7 +17,7 @@ from xmodule.modulestore import Location
from django.http import QueryDict
-from . import system_test
+from . import get_test_system
class CapaFactory(object):
@@ -110,7 +110,7 @@ class CapaFactory(object):
# since everything else is a string.
model_data['attempts'] = int(attempts)
- system = system_test()
+ system = get_test_system()
system.render_template = Mock(return_value="
Test Template HTML
")
module = CapaModule(system, location, descriptor, model_data)
@@ -921,7 +921,7 @@ class CapaModuleTest(unittest.TestCase):
# is asked to render itself as HTML
module.lcp.get_html = Mock(side_effect=Exception("Test"))
- # Stub out the system_test rendering function
+ # Stub out the get_test_system rendering function
module.system.render_template = Mock(return_value="Test Template HTML
")
# Turn off DEBUG
diff --git a/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py b/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
index d30d98049b..2599a35dab 100644
--- a/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
+++ b/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
@@ -18,7 +18,7 @@ import logging
log = logging.getLogger(__name__)
-from . import system_test
+from . import get_test_system
ORG = 'edX'
COURSE = 'open_ended' # name of directory with course data
@@ -68,8 +68,8 @@ class OpenEndedChildTest(unittest.TestCase):
descriptor = Mock()
def setUp(self):
- self.system_test = system_test()
- self.openendedchild = OpenEndedChild(self.system_test, self.location,
+ self.get_test_system = get_test_system()
+ self.openendedchild = OpenEndedChild(self.get_test_system, self.location,
self.definition, self.descriptor, self.static_data, self.metadata)
def test_latest_answer_empty(self):
@@ -81,7 +81,7 @@ class OpenEndedChildTest(unittest.TestCase):
self.assertEqual(answer, None)
def test_latest_post_assessment_empty(self):
- answer = self.openendedchild.latest_post_assessment(self.system_test)
+ answer = self.openendedchild.latest_post_assessment(self.get_test_system)
self.assertEqual(answer, "")
def test_new_history_entry(self):
@@ -116,7 +116,7 @@ class OpenEndedChildTest(unittest.TestCase):
post_assessment = "Post assessment"
self.openendedchild.record_latest_post_assessment(post_assessment)
self.assertEqual(post_assessment,
- self.openendedchild.latest_post_assessment(self.system_test))
+ self.openendedchild.latest_post_assessment(self.get_test_system))
def test_get_score(self):
new_answer = "New Answer"
@@ -134,7 +134,7 @@ class OpenEndedChildTest(unittest.TestCase):
self.assertEqual(score['total'], self.static_data['max_score'])
def test_reset(self):
- self.openendedchild.reset(self.system_test)
+ self.openendedchild.reset(self.get_test_system)
state = json.loads(self.openendedchild.get_instance_state())
self.assertEqual(state['child_state'], OpenEndedChild.INITIAL)
@@ -193,19 +193,19 @@ class OpenEndedModuleTest(unittest.TestCase):
descriptor = Mock()
def setUp(self):
- self.system_test = system_test()
+ self.get_test_system = get_test_system()
- self.system_test.location = self.location
+ self.get_test_system.location = self.location
self.mock_xqueue = MagicMock()
self.mock_xqueue.send_to_queue.return_value = (None, "Message")
def constructed_callback(dispatch="score_update"):
return dispatch
- self.system_test.xqueue = {'interface': self.mock_xqueue, 'construct_callback': constructed_callback,
+ self.get_test_system.xqueue = {'interface': self.mock_xqueue, 'construct_callback': constructed_callback,
'default_queuename': 'testqueue',
'waittime': 1}
- self.openendedmodule = OpenEndedModule(self.system_test, self.location,
+ self.openendedmodule = OpenEndedModule(self.get_test_system, self.location,
self.definition, self.descriptor, self.static_data, self.metadata)
def test_message_post(self):
@@ -214,7 +214,7 @@ class OpenEndedModuleTest(unittest.TestCase):
'grader_id': '1',
'score': 3}
qtime = datetime.strftime(datetime.now(), xqueue_interface.dateformat)
- student_info = {'anonymous_student_id': self.system_test.anonymous_student_id,
+ student_info = {'anonymous_student_id': self.get_test_system.anonymous_student_id,
'submission_time': qtime}
contents = {
'feedback': get['feedback'],
@@ -224,7 +224,7 @@ class OpenEndedModuleTest(unittest.TestCase):
'student_info': json.dumps(student_info)
}
- result = self.openendedmodule.message_post(get, self.system_test)
+ result = self.openendedmodule.message_post(get, self.get_test_system)
self.assertTrue(result['success'])
# make sure it's actually sending something we want to the queue
self.mock_xqueue.send_to_queue.assert_called_with(body=json.dumps(contents), header=ANY)
@@ -235,7 +235,7 @@ class OpenEndedModuleTest(unittest.TestCase):
def test_send_to_grader(self):
submission = "This is a student submission"
qtime = datetime.strftime(datetime.now(), xqueue_interface.dateformat)
- student_info = {'anonymous_student_id': self.system_test.anonymous_student_id,
+ student_info = {'anonymous_student_id': self.get_test_system.anonymous_student_id,
'submission_time': qtime}
contents = self.openendedmodule.payload.copy()
contents.update({
@@ -243,7 +243,7 @@ class OpenEndedModuleTest(unittest.TestCase):
'student_response': submission,
'max_score': self.max_score
})
- result = self.openendedmodule.send_to_grader(submission, self.system_test)
+ result = self.openendedmodule.send_to_grader(submission, self.get_test_system)
self.assertTrue(result)
self.mock_xqueue.send_to_queue.assert_called_with(body=json.dumps(contents), header=ANY)
@@ -257,7 +257,7 @@ class OpenEndedModuleTest(unittest.TestCase):
}
get = {'queuekey': "abcd",
'xqueue_body': score_msg}
- self.openendedmodule.update_score(get, self.system_test)
+ self.openendedmodule.update_score(get, self.get_test_system)
def update_score_single(self):
self.openendedmodule.new_history_entry("New Entry")
@@ -280,11 +280,11 @@ class OpenEndedModuleTest(unittest.TestCase):
}
get = {'queuekey': "abcd",
'xqueue_body': json.dumps(score_msg)}
- self.openendedmodule.update_score(get, self.system_test)
+ self.openendedmodule.update_score(get, self.get_test_system)
def test_latest_post_assessment(self):
self.update_score_single()
- assessment = self.openendedmodule.latest_post_assessment(self.system_test)
+ assessment = self.openendedmodule.latest_post_assessment(self.get_test_system)
self.assertFalse(assessment == '')
# check for errors
self.assertFalse('errors' in assessment)
@@ -369,8 +369,8 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
definition = {'prompt': etree.XML(prompt), 'rubric': etree.XML(rubric), 'task_xml': [task_xml1, task_xml2]}
full_definition = definition_template.format(prompt=prompt, rubric=rubric, task1=task_xml1, task2=task_xml2)
descriptor = Mock(data=full_definition)
- system_test = system_test()
- combinedoe_container = CombinedOpenEndedModule(system_test,
+ get_test_system = get_test_system()
+ combinedoe_container = CombinedOpenEndedModule(get_test_system,
location,
descriptor,
model_data={'data': full_definition, 'weight': '1'})
@@ -378,7 +378,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
def setUp(self):
# TODO: this constructor call is definitely wrong, but neither branch
# of the merge matches the module constructor. Someone (Vik?) should fix this.
- self.combinedoe = CombinedOpenEndedV1Module(self.system_test,
+ self.combinedoe = CombinedOpenEndedV1Module(self.get_test_system,
self.location,
self.definition,
self.descriptor,
@@ -438,7 +438,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
for xml in xml_to_test:
definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(self.rubric), 'task_xml': xml}
descriptor = Mock(data=definition)
- combinedoe = CombinedOpenEndedV1Module(self.system_test,
+ combinedoe = CombinedOpenEndedV1Module(self.get_test_system,
self.location,
definition,
descriptor,
@@ -468,7 +468,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(rubric),
'task_xml': [self.task_xml1, self.task_xml2]}
descriptor = Mock(data=definition)
- combinedoe = CombinedOpenEndedV1Module(self.system_test,
+ combinedoe = CombinedOpenEndedV1Module(self.get_test_system,
self.location,
definition,
descriptor,
@@ -490,8 +490,8 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
hint = "blah"
def setUp(self):
- self.system_test = system_test()
- self.system_test.xqueue['interface'] = Mock(
+ self.get_test_system = get_test_system()
+ self.get_test_system.xqueue['interface'] = Mock(
send_to_queue=Mock(side_effect=[1, "queued"])
)
self.setup_modulestore(COURSE)
diff --git a/common/lib/xmodule/xmodule/tests/test_conditional.py b/common/lib/xmodule/xmodule/tests/test_conditional.py
index f0c777c202..3616ad0eb7 100644
--- a/common/lib/xmodule/xmodule/tests/test_conditional.py
+++ b/common/lib/xmodule/xmodule/tests/test_conditional.py
@@ -15,7 +15,7 @@ from xmodule.tests.test_export import DATA_DIR
ORG = 'test_org'
COURSE = 'conditional' # name of directory with course data
-from . import system_test
+from . import get_test_system
class DummySystem(ImportSystem):
@@ -103,11 +103,11 @@ class ConditionalModuleBasicTest(unittest.TestCase):
"""
def setUp(self):
- self.system_test = system_test()
+ self.get_test_system = get_test_system()
def test_icon_class(self):
'''verify that get_icon_class works independent of condition satisfaction'''
- modules = ConditionalFactory.create(self.system_test)
+ modules = ConditionalFactory.create(self.get_test_system)
for attempted in ["false", "true"]:
for icon_class in [ 'other', 'problem', 'video']:
modules['source_module'].is_attempted = attempted
@@ -116,8 +116,8 @@ class ConditionalModuleBasicTest(unittest.TestCase):
def test_get_html(self):
- modules = ConditionalFactory.create(self.system_test)
- # because system_test returns the repr of the context dict passed to render_template,
+ modules = ConditionalFactory.create(self.get_test_system)
+ # because get_test_system returns the repr of the context dict passed to render_template,
# we reverse it here
html = modules['cond_module'].get_html()
html_dict = literal_eval(html)
@@ -126,7 +126,7 @@ class ConditionalModuleBasicTest(unittest.TestCase):
self.assertEqual(html_dict['depends'], 'i4x-edX-conditional_test-problem-SampleProblem')
def test_handle_ajax(self):
- modules = ConditionalFactory.create(self.system_test)
+ modules = ConditionalFactory.create(self.get_test_system)
modules['source_module'].is_attempted = "false"
ajax = json.loads(modules['cond_module'].handle_ajax('', ''))
print "ajax: ", ajax
@@ -145,7 +145,7 @@ class ConditionalModuleBasicTest(unittest.TestCase):
Check that handle_ajax works properly if the source is really an ErrorModule,
and that the condition is not satisfied.
'''
- modules = ConditionalFactory.create(self.system_test, source_is_error_module=True)
+ modules = ConditionalFactory.create(self.get_test_system, source_is_error_module=True)
ajax = json.loads(modules['cond_module'].handle_ajax('', ''))
html = ajax['html']
self.assertFalse(any(['This is a secret' in item for item in html]))
@@ -161,7 +161,7 @@ class ConditionalModuleXmlTest(unittest.TestCase):
return DummySystem(load_error_modules)
def setUp(self):
- self.system_test = system_test()
+ self.get_test_system = get_test_system()
def get_course(self, name):
"""Get a test course by directory name. If there's more than one, error."""
@@ -187,7 +187,7 @@ class ConditionalModuleXmlTest(unittest.TestCase):
location = descriptor
descriptor = self.modulestore.get_instance(course.id, location, depth=None)
location = descriptor.location
- return descriptor.xmodule(self.system_test)
+ return descriptor.xmodule(self.get_test_system)
# edx - HarvardX
# cond_test - ER22x
@@ -195,8 +195,8 @@ class ConditionalModuleXmlTest(unittest.TestCase):
def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/', course_namespace=None):
return text
- self.system_test.replace_urls = replace_urls
- self.system_test.get_module = inner_get_module
+ self.get_test_system.replace_urls = replace_urls
+ self.get_test_system.get_module = inner_get_module
module = inner_get_module(location)
print "module: ", module
diff --git a/common/lib/xmodule/xmodule/tests/test_error_module.py b/common/lib/xmodule/xmodule/tests/test_error_module.py
index 1595b1f91a..82b181bb9f 100644
--- a/common/lib/xmodule/xmodule/tests/test_error_module.py
+++ b/common/lib/xmodule/xmodule/tests/test_error_module.py
@@ -2,7 +2,7 @@
Tests for ErrorModule and NonStaffErrorModule
"""
import unittest
-from xmodule.tests import system_test
+from xmodule.tests import get_test_system
import xmodule.error_module as error_module
from xmodule.modulestore import Location
from xmodule.x_module import XModuleDescriptor
@@ -14,7 +14,7 @@ class TestErrorModule(unittest.TestCase):
Tests for ErrorModule and ErrorDescriptor
"""
def setUp(self):
- self.system = system_test()
+ self.system = get_test_system()
self.org = "org"
self.course = "course"
self.location = Location(['i4x', self.org, self.course, None, None])
@@ -50,7 +50,7 @@ class TestNonStaffErrorModule(unittest.TestCase):
Tests for NonStaffErrorModule and NonStaffErrorDescriptor
"""
def setUp(self):
- self.system = system_test()
+ self.system = get_test_system()
self.org = "org"
self.course = "course"
self.location = Location(['i4x', self.org, self.course, None, None])
diff --git a/common/lib/xmodule/xmodule/tests/test_html_module.py b/common/lib/xmodule/xmodule/tests/test_html_module.py
index 610e06f435..31f9fc91c5 100644
--- a/common/lib/xmodule/xmodule/tests/test_html_module.py
+++ b/common/lib/xmodule/xmodule/tests/test_html_module.py
@@ -5,7 +5,7 @@ from mock import Mock
from xmodule.html_module import HtmlModule
from xmodule.modulestore import Location
-from . import system_test
+from . import get_test_system
class HtmlModuleSubstitutionTestCase(unittest.TestCase):
location = Location(["i4x", "edX", "toy", "html", "simple_html"])
@@ -14,7 +14,7 @@ class HtmlModuleSubstitutionTestCase(unittest.TestCase):
def test_substitution_works(self):
sample_xml = '''%%USER_ID%%'''
module_data = {'data': sample_xml}
- module_system = system_test()
+ module_system = get_test_system()
module = HtmlModule(module_system, self.location, self.descriptor, module_data)
self.assertEqual(module.get_html(), str(module_system.anonymous_student_id))
@@ -26,14 +26,14 @@ class HtmlModuleSubstitutionTestCase(unittest.TestCase):