Commit b93f00e0 by lapentab

Rename system_test to get_test_system

parent 7516fb56
...@@ -29,14 +29,14 @@ open_ended_grading_interface = { ...@@ -29,14 +29,14 @@ open_ended_grading_interface = {
} }
def system_test(): def get_test_system():
""" """
Construct a test ModuleSystem instance. Construct a test ModuleSystem instance.
By default, the render_template() method simply returns the repr of the By default, the render_template() method simply returns the repr of the
context it is passed. You can override this behavior by monkey patching:: 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 system.render_template = my_render_func
where `my_render_func` is a function of the form my_render_func(template, context). where `my_render_func` is a function of the form my_render_func(template, context).
......
...@@ -8,7 +8,7 @@ from mock import Mock ...@@ -8,7 +8,7 @@ from mock import Mock
from xmodule.annotatable_module import AnnotatableModule from xmodule.annotatable_module import AnnotatableModule
from xmodule.modulestore import Location from xmodule.modulestore import Location
from . import system_test from . import get_test_system
class AnnotatableModuleTestCase(unittest.TestCase): class AnnotatableModuleTestCase(unittest.TestCase):
location = Location(["i4x", "edX", "toy", "annotatable", "guided_discussion"]) location = Location(["i4x", "edX", "toy", "annotatable", "guided_discussion"])
...@@ -32,7 +32,7 @@ class AnnotatableModuleTestCase(unittest.TestCase): ...@@ -32,7 +32,7 @@ class AnnotatableModuleTestCase(unittest.TestCase):
module_data = {'data': sample_xml} module_data = {'data': sample_xml}
def setUp(self): 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): def test_annotation_data_attr(self):
el = etree.fromstring('<annotation title="bar" body="foo" problem="0">test</annotation>') el = etree.fromstring('<annotation title="bar" body="foo" problem="0">test</annotation>')
......
...@@ -17,7 +17,7 @@ from xmodule.modulestore import Location ...@@ -17,7 +17,7 @@ from xmodule.modulestore import Location
from django.http import QueryDict from django.http import QueryDict
from . import system_test from . import get_test_system
class CapaFactory(object): class CapaFactory(object):
...@@ -110,7 +110,7 @@ class CapaFactory(object): ...@@ -110,7 +110,7 @@ class CapaFactory(object):
# since everything else is a string. # since everything else is a string.
model_data['attempts'] = int(attempts) model_data['attempts'] = int(attempts)
system = system_test() system = get_test_system()
system.render_template = Mock(return_value="<div>Test Template HTML</div>") system.render_template = Mock(return_value="<div>Test Template HTML</div>")
module = CapaModule(system, location, descriptor, model_data) module = CapaModule(system, location, descriptor, model_data)
...@@ -921,7 +921,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -921,7 +921,7 @@ class CapaModuleTest(unittest.TestCase):
# is asked to render itself as HTML # is asked to render itself as HTML
module.lcp.get_html = Mock(side_effect=Exception("Test")) 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="<div>Test Template HTML</div>") module.system.render_template = Mock(return_value="<div>Test Template HTML</div>")
# Turn off DEBUG # Turn off DEBUG
......
...@@ -18,7 +18,7 @@ import logging ...@@ -18,7 +18,7 @@ import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
from . import system_test from . import get_test_system
ORG = 'edX' ORG = 'edX'
COURSE = 'open_ended' # name of directory with course data COURSE = 'open_ended' # name of directory with course data
...@@ -68,8 +68,8 @@ class OpenEndedChildTest(unittest.TestCase): ...@@ -68,8 +68,8 @@ class OpenEndedChildTest(unittest.TestCase):
descriptor = Mock() descriptor = Mock()
def setUp(self): def setUp(self):
self.system_test = system_test() self.get_test_system = get_test_system()
self.openendedchild = OpenEndedChild(self.system_test, self.location, self.openendedchild = OpenEndedChild(self.get_test_system, self.location,
self.definition, self.descriptor, self.static_data, self.metadata) self.definition, self.descriptor, self.static_data, self.metadata)
def test_latest_answer_empty(self): def test_latest_answer_empty(self):
...@@ -81,7 +81,7 @@ class OpenEndedChildTest(unittest.TestCase): ...@@ -81,7 +81,7 @@ class OpenEndedChildTest(unittest.TestCase):
self.assertEqual(answer, None) self.assertEqual(answer, None)
def test_latest_post_assessment_empty(self): 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, "") self.assertEqual(answer, "")
def test_new_history_entry(self): def test_new_history_entry(self):
...@@ -116,7 +116,7 @@ class OpenEndedChildTest(unittest.TestCase): ...@@ -116,7 +116,7 @@ class OpenEndedChildTest(unittest.TestCase):
post_assessment = "Post assessment" post_assessment = "Post assessment"
self.openendedchild.record_latest_post_assessment(post_assessment) self.openendedchild.record_latest_post_assessment(post_assessment)
self.assertEqual(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): def test_get_score(self):
new_answer = "New Answer" new_answer = "New Answer"
...@@ -134,7 +134,7 @@ class OpenEndedChildTest(unittest.TestCase): ...@@ -134,7 +134,7 @@ class OpenEndedChildTest(unittest.TestCase):
self.assertEqual(score['total'], self.static_data['max_score']) self.assertEqual(score['total'], self.static_data['max_score'])
def test_reset(self): 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()) state = json.loads(self.openendedchild.get_instance_state())
self.assertEqual(state['child_state'], OpenEndedChild.INITIAL) self.assertEqual(state['child_state'], OpenEndedChild.INITIAL)
...@@ -193,19 +193,19 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -193,19 +193,19 @@ class OpenEndedModuleTest(unittest.TestCase):
descriptor = Mock() descriptor = Mock()
def setUp(self): 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 = MagicMock()
self.mock_xqueue.send_to_queue.return_value = (None, "Message") self.mock_xqueue.send_to_queue.return_value = (None, "Message")
def constructed_callback(dispatch="score_update"): def constructed_callback(dispatch="score_update"):
return dispatch 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', 'default_queuename': 'testqueue',
'waittime': 1} '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) self.definition, self.descriptor, self.static_data, self.metadata)
def test_message_post(self): def test_message_post(self):
...@@ -214,7 +214,7 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -214,7 +214,7 @@ class OpenEndedModuleTest(unittest.TestCase):
'grader_id': '1', 'grader_id': '1',
'score': 3} 'score': 3}
qtime = datetime.strftime(datetime.now(), xqueue_interface.dateformat) 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} 'submission_time': qtime}
contents = { contents = {
'feedback': get['feedback'], 'feedback': get['feedback'],
...@@ -224,7 +224,7 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -224,7 +224,7 @@ class OpenEndedModuleTest(unittest.TestCase):
'student_info': json.dumps(student_info) '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']) self.assertTrue(result['success'])
# make sure it's actually sending something we want to the queue # 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) self.mock_xqueue.send_to_queue.assert_called_with(body=json.dumps(contents), header=ANY)
...@@ -235,7 +235,7 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -235,7 +235,7 @@ class OpenEndedModuleTest(unittest.TestCase):
def test_send_to_grader(self): def test_send_to_grader(self):
submission = "This is a student submission" submission = "This is a student submission"
qtime = datetime.strftime(datetime.now(), xqueue_interface.dateformat) 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} 'submission_time': qtime}
contents = self.openendedmodule.payload.copy() contents = self.openendedmodule.payload.copy()
contents.update({ contents.update({
...@@ -243,7 +243,7 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -243,7 +243,7 @@ class OpenEndedModuleTest(unittest.TestCase):
'student_response': submission, 'student_response': submission,
'max_score': self.max_score '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.assertTrue(result)
self.mock_xqueue.send_to_queue.assert_called_with(body=json.dumps(contents), header=ANY) self.mock_xqueue.send_to_queue.assert_called_with(body=json.dumps(contents), header=ANY)
...@@ -257,7 +257,7 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -257,7 +257,7 @@ class OpenEndedModuleTest(unittest.TestCase):
} }
get = {'queuekey': "abcd", get = {'queuekey': "abcd",
'xqueue_body': score_msg} '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): def update_score_single(self):
self.openendedmodule.new_history_entry("New Entry") self.openendedmodule.new_history_entry("New Entry")
...@@ -280,11 +280,11 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -280,11 +280,11 @@ class OpenEndedModuleTest(unittest.TestCase):
} }
get = {'queuekey': "abcd", get = {'queuekey': "abcd",
'xqueue_body': json.dumps(score_msg)} '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): def test_latest_post_assessment(self):
self.update_score_single() 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 == '') self.assertFalse(assessment == '')
# check for errors # check for errors
self.assertFalse('errors' in assessment) self.assertFalse('errors' in assessment)
...@@ -369,8 +369,8 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): ...@@ -369,8 +369,8 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
definition = {'prompt': etree.XML(prompt), 'rubric': etree.XML(rubric), 'task_xml': [task_xml1, task_xml2]} 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) full_definition = definition_template.format(prompt=prompt, rubric=rubric, task1=task_xml1, task2=task_xml2)
descriptor = Mock(data=full_definition) descriptor = Mock(data=full_definition)
system_test = system_test() get_test_system = get_test_system()
combinedoe_container = CombinedOpenEndedModule(system_test, combinedoe_container = CombinedOpenEndedModule(get_test_system,
location, location,
descriptor, descriptor,
model_data={'data': full_definition, 'weight': '1'}) model_data={'data': full_definition, 'weight': '1'})
...@@ -378,7 +378,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): ...@@ -378,7 +378,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
def setUp(self): def setUp(self):
# TODO: this constructor call is definitely wrong, but neither branch # TODO: this constructor call is definitely wrong, but neither branch
# of the merge matches the module constructor. Someone (Vik?) should fix this. # 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.location,
self.definition, self.definition,
self.descriptor, self.descriptor,
...@@ -438,7 +438,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): ...@@ -438,7 +438,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
for xml in xml_to_test: for xml in xml_to_test:
definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(self.rubric), 'task_xml': xml} definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(self.rubric), 'task_xml': xml}
descriptor = Mock(data=definition) descriptor = Mock(data=definition)
combinedoe = CombinedOpenEndedV1Module(self.system_test, combinedoe = CombinedOpenEndedV1Module(self.get_test_system,
self.location, self.location,
definition, definition,
descriptor, descriptor,
...@@ -468,7 +468,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase): ...@@ -468,7 +468,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(rubric), definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(rubric),
'task_xml': [self.task_xml1, self.task_xml2]} 'task_xml': [self.task_xml1, self.task_xml2]}
descriptor = Mock(data=definition) descriptor = Mock(data=definition)
combinedoe = CombinedOpenEndedV1Module(self.system_test, combinedoe = CombinedOpenEndedV1Module(self.get_test_system,
self.location, self.location,
definition, definition,
descriptor, descriptor,
...@@ -490,8 +490,8 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore): ...@@ -490,8 +490,8 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
hint = "blah" hint = "blah"
def setUp(self): def setUp(self):
self.system_test = system_test() self.get_test_system = get_test_system()
self.system_test.xqueue['interface'] = Mock( self.get_test_system.xqueue['interface'] = Mock(
send_to_queue=Mock(side_effect=[1, "queued"]) send_to_queue=Mock(side_effect=[1, "queued"])
) )
self.setup_modulestore(COURSE) self.setup_modulestore(COURSE)
......
...@@ -15,7 +15,7 @@ from xmodule.tests.test_export import DATA_DIR ...@@ -15,7 +15,7 @@ from xmodule.tests.test_export import DATA_DIR
ORG = 'test_org' ORG = 'test_org'
COURSE = 'conditional' # name of directory with course data COURSE = 'conditional' # name of directory with course data
from . import system_test from . import get_test_system
class DummySystem(ImportSystem): class DummySystem(ImportSystem):
...@@ -103,11 +103,11 @@ class ConditionalModuleBasicTest(unittest.TestCase): ...@@ -103,11 +103,11 @@ class ConditionalModuleBasicTest(unittest.TestCase):
""" """
def setUp(self): def setUp(self):
self.system_test = system_test() self.get_test_system = get_test_system()
def test_icon_class(self): def test_icon_class(self):
'''verify that get_icon_class works independent of condition satisfaction''' '''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 attempted in ["false", "true"]:
for icon_class in [ 'other', 'problem', 'video']: for icon_class in [ 'other', 'problem', 'video']:
modules['source_module'].is_attempted = attempted modules['source_module'].is_attempted = attempted
...@@ -116,8 +116,8 @@ class ConditionalModuleBasicTest(unittest.TestCase): ...@@ -116,8 +116,8 @@ class ConditionalModuleBasicTest(unittest.TestCase):
def test_get_html(self): def test_get_html(self):
modules = ConditionalFactory.create(self.system_test) modules = ConditionalFactory.create(self.get_test_system)
# because system_test returns the repr of the context dict passed to render_template, # because get_test_system returns the repr of the context dict passed to render_template,
# we reverse it here # we reverse it here
html = modules['cond_module'].get_html() html = modules['cond_module'].get_html()
html_dict = literal_eval(html) html_dict = literal_eval(html)
...@@ -126,7 +126,7 @@ class ConditionalModuleBasicTest(unittest.TestCase): ...@@ -126,7 +126,7 @@ class ConditionalModuleBasicTest(unittest.TestCase):
self.assertEqual(html_dict['depends'], 'i4x-edX-conditional_test-problem-SampleProblem') self.assertEqual(html_dict['depends'], 'i4x-edX-conditional_test-problem-SampleProblem')
def test_handle_ajax(self): def test_handle_ajax(self):
modules = ConditionalFactory.create(self.system_test) modules = ConditionalFactory.create(self.get_test_system)
modules['source_module'].is_attempted = "false" modules['source_module'].is_attempted = "false"
ajax = json.loads(modules['cond_module'].handle_ajax('', '')) ajax = json.loads(modules['cond_module'].handle_ajax('', ''))
print "ajax: ", ajax print "ajax: ", ajax
...@@ -145,7 +145,7 @@ class ConditionalModuleBasicTest(unittest.TestCase): ...@@ -145,7 +145,7 @@ class ConditionalModuleBasicTest(unittest.TestCase):
Check that handle_ajax works properly if the source is really an ErrorModule, Check that handle_ajax works properly if the source is really an ErrorModule,
and that the condition is not satisfied. 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('', '')) ajax = json.loads(modules['cond_module'].handle_ajax('', ''))
html = ajax['html'] html = ajax['html']
self.assertFalse(any(['This is a secret' in item for item in html])) self.assertFalse(any(['This is a secret' in item for item in html]))
...@@ -161,7 +161,7 @@ class ConditionalModuleXmlTest(unittest.TestCase): ...@@ -161,7 +161,7 @@ class ConditionalModuleXmlTest(unittest.TestCase):
return DummySystem(load_error_modules) return DummySystem(load_error_modules)
def setUp(self): def setUp(self):
self.system_test = system_test() self.get_test_system = get_test_system()
def get_course(self, name): def get_course(self, name):
"""Get a test course by directory name. If there's more than one, error.""" """Get a test course by directory name. If there's more than one, error."""
...@@ -187,7 +187,7 @@ class ConditionalModuleXmlTest(unittest.TestCase): ...@@ -187,7 +187,7 @@ class ConditionalModuleXmlTest(unittest.TestCase):
location = descriptor location = descriptor
descriptor = self.modulestore.get_instance(course.id, location, depth=None) descriptor = self.modulestore.get_instance(course.id, location, depth=None)
location = descriptor.location location = descriptor.location
return descriptor.xmodule(self.system_test) return descriptor.xmodule(self.get_test_system)
# edx - HarvardX # edx - HarvardX
# cond_test - ER22x # cond_test - ER22x
...@@ -195,8 +195,8 @@ class ConditionalModuleXmlTest(unittest.TestCase): ...@@ -195,8 +195,8 @@ class ConditionalModuleXmlTest(unittest.TestCase):
def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/', course_namespace=None): def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/', course_namespace=None):
return text return text
self.system_test.replace_urls = replace_urls self.get_test_system.replace_urls = replace_urls
self.system_test.get_module = inner_get_module self.get_test_system.get_module = inner_get_module
module = inner_get_module(location) module = inner_get_module(location)
print "module: ", module print "module: ", module
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Tests for ErrorModule and NonStaffErrorModule Tests for ErrorModule and NonStaffErrorModule
""" """
import unittest import unittest
from xmodule.tests import system_test from xmodule.tests import get_test_system
import xmodule.error_module as error_module import xmodule.error_module as error_module
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.x_module import XModuleDescriptor from xmodule.x_module import XModuleDescriptor
...@@ -14,7 +14,7 @@ class TestErrorModule(unittest.TestCase): ...@@ -14,7 +14,7 @@ class TestErrorModule(unittest.TestCase):
Tests for ErrorModule and ErrorDescriptor Tests for ErrorModule and ErrorDescriptor
""" """
def setUp(self): def setUp(self):
self.system = system_test() self.system = get_test_system()
self.org = "org" self.org = "org"
self.course = "course" self.course = "course"
self.location = Location(['i4x', self.org, self.course, None, None]) self.location = Location(['i4x', self.org, self.course, None, None])
...@@ -50,7 +50,7 @@ class TestNonStaffErrorModule(unittest.TestCase): ...@@ -50,7 +50,7 @@ class TestNonStaffErrorModule(unittest.TestCase):
Tests for NonStaffErrorModule and NonStaffErrorDescriptor Tests for NonStaffErrorModule and NonStaffErrorDescriptor
""" """
def setUp(self): def setUp(self):
self.system = system_test() self.system = get_test_system()
self.org = "org" self.org = "org"
self.course = "course" self.course = "course"
self.location = Location(['i4x', self.org, self.course, None, None]) self.location = Location(['i4x', self.org, self.course, None, None])
......
...@@ -5,7 +5,7 @@ from mock import Mock ...@@ -5,7 +5,7 @@ from mock import Mock
from xmodule.html_module import HtmlModule from xmodule.html_module import HtmlModule
from xmodule.modulestore import Location from xmodule.modulestore import Location
from . import system_test from . import get_test_system
class HtmlModuleSubstitutionTestCase(unittest.TestCase): class HtmlModuleSubstitutionTestCase(unittest.TestCase):
location = Location(["i4x", "edX", "toy", "html", "simple_html"]) location = Location(["i4x", "edX", "toy", "html", "simple_html"])
...@@ -14,7 +14,7 @@ class HtmlModuleSubstitutionTestCase(unittest.TestCase): ...@@ -14,7 +14,7 @@ class HtmlModuleSubstitutionTestCase(unittest.TestCase):
def test_substitution_works(self): def test_substitution_works(self):
sample_xml = '''%%USER_ID%%''' sample_xml = '''%%USER_ID%%'''
module_data = {'data': sample_xml} module_data = {'data': sample_xml}
module_system = system_test() module_system = get_test_system()
module = HtmlModule(module_system, self.location, self.descriptor, module_data) module = HtmlModule(module_system, self.location, self.descriptor, module_data)
self.assertEqual(module.get_html(), str(module_system.anonymous_student_id)) self.assertEqual(module.get_html(), str(module_system.anonymous_student_id))
...@@ -26,14 +26,14 @@ class HtmlModuleSubstitutionTestCase(unittest.TestCase): ...@@ -26,14 +26,14 @@ class HtmlModuleSubstitutionTestCase(unittest.TestCase):
</html> </html>
''' '''
module_data = {'data': sample_xml} module_data = {'data': sample_xml}
module = HtmlModule(system_test(), self.location, self.descriptor, module_data) module = HtmlModule(get_test_system(), self.location, self.descriptor, module_data)
self.assertEqual(module.get_html(), sample_xml) self.assertEqual(module.get_html(), sample_xml)
def test_substitution_without_anonymous_student_id(self): def test_substitution_without_anonymous_student_id(self):
sample_xml = '''%%USER_ID%%''' sample_xml = '''%%USER_ID%%'''
module_data = {'data': sample_xml} module_data = {'data': sample_xml}
module_system = system_test() module_system = get_test_system()
module_system.anonymous_student_id = None module_system.anonymous_student_id = None
module = HtmlModule(module_system, self.location, self.descriptor, module_data) module = HtmlModule(module_system, self.location, self.descriptor, module_data)
self.assertEqual(module.get_html(), sample_xml) self.assertEqual(module.get_html(), sample_xml)
......
import unittest import unittest
from xmodule.modulestore import Location from xmodule.modulestore import Location
from .import system_test from .import get_test_system
from test_util_open_ended import MockQueryDict, DummyModulestore from test_util_open_ended import MockQueryDict, DummyModulestore
import json import json
...@@ -39,8 +39,8 @@ class PeerGradingModuleTest(unittest.TestCase, DummyModulestore): ...@@ -39,8 +39,8 @@ class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
Create a peer grading module from a test system Create a peer grading module from a test system
@return: @return:
""" """
self.system_test = system_test() self.get_test_system = get_test_system()
self.system_test.open_ended_grading_interface = None self.get_test_system.open_ended_grading_interface = None
self.setup_modulestore(COURSE) self.setup_modulestore(COURSE)
self.peer_grading = self.get_module_from_location(self.problem_location, COURSE) self.peer_grading = self.get_module_from_location(self.problem_location, COURSE)
...@@ -151,8 +151,8 @@ class PeerGradingModuleScoredTest(unittest.TestCase, DummyModulestore): ...@@ -151,8 +151,8 @@ class PeerGradingModuleScoredTest(unittest.TestCase, DummyModulestore):
Create a peer grading module from a test system Create a peer grading module from a test system
@return: @return:
""" """
self.system_test = system_test() self.get_test_system = get_test_system()
self.system_test.open_ended_grading_interface = None self.get_test_system.open_ended_grading_interface = None
self.setup_modulestore(COURSE) self.setup_modulestore(COURSE)
def test_metadata_load(self): def test_metadata_load(self):
......
...@@ -5,7 +5,7 @@ import unittest ...@@ -5,7 +5,7 @@ import unittest
from xmodule.progress import Progress from xmodule.progress import Progress
from xmodule import x_module from xmodule import x_module
from . import system_test from . import get_test_system
class ProgressTest(unittest.TestCase): class ProgressTest(unittest.TestCase):
...@@ -134,6 +134,6 @@ class ModuleProgressTest(unittest.TestCase): ...@@ -134,6 +134,6 @@ class ModuleProgressTest(unittest.TestCase):
''' '''
def test_xmodule_default(self): def test_xmodule_default(self):
'''Make sure default get_progress exists, returns None''' '''Make sure default get_progress exists, returns None'''
xm = x_module.XModule(system_test(), 'a://b/c/d/e', None, {}) xm = x_module.XModule(get_test_system(), 'a://b/c/d/e', None, {})
p = xm.get_progress() p = xm.get_progress()
self.assertEqual(p, None) self.assertEqual(p, None)
...@@ -6,7 +6,7 @@ from xmodule.open_ended_grading_classes.self_assessment_module import SelfAssess ...@@ -6,7 +6,7 @@ from xmodule.open_ended_grading_classes.self_assessment_module import SelfAssess
from xmodule.modulestore import Location from xmodule.modulestore import Location
from lxml import etree from lxml import etree
from . import system_test from . import get_test_system
import test_util_open_ended import test_util_open_ended
...@@ -51,7 +51,7 @@ class SelfAssessmentTest(unittest.TestCase): ...@@ -51,7 +51,7 @@ class SelfAssessmentTest(unittest.TestCase):
'skip_basic_checks': False, 'skip_basic_checks': False,
} }
self.module = SelfAssessmentModule(system_test(), self.location, self.module = SelfAssessmentModule(get_test_system(), self.location,
self.definition, self.definition,
self.descriptor, self.descriptor,
static_data) static_data)
......
from .import system_test from .import get_test_system
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.modulestore.xml import ImportSystem, XMLModuleStore from xmodule.modulestore.xml import ImportSystem, XMLModuleStore
from xmodule.tests.test_export import DATA_DIR from xmodule.tests.test_export import DATA_DIR
...@@ -37,7 +37,7 @@ class DummyModulestore(object): ...@@ -37,7 +37,7 @@ class DummyModulestore(object):
""" """
A mixin that allows test classes to have convenience functions to get a module given a location A mixin that allows test classes to have convenience functions to get a module given a location
""" """
system_test = system_test() get_test_system = get_test_system()
def setup_modulestore(self, name): def setup_modulestore(self, name):
self.modulestore = XMLModuleStore(DATA_DIR, course_dirs=[name]) self.modulestore = XMLModuleStore(DATA_DIR, course_dirs=[name])
...@@ -52,4 +52,4 @@ class DummyModulestore(object): ...@@ -52,4 +52,4 @@ class DummyModulestore(object):
if not isinstance(location, Location): if not isinstance(location, Location):
location = Location(location) location = Location(location)
descriptor = self.modulestore.get_instance(course.id, location, depth=None) descriptor = self.modulestore.get_instance(course.id, location, depth=None)
return descriptor.xmodule(self.system_test) return descriptor.xmodule(self.get_test_system)
...@@ -6,7 +6,7 @@ from xblock.core import Scope, String, Object, Boolean ...@@ -6,7 +6,7 @@ from xblock.core import Scope, String, Object, Boolean
from xmodule.fields import Date, StringyInteger, StringyFloat from xmodule.fields import Date, StringyInteger, StringyFloat
from xmodule.xml_module import XmlDescriptor from xmodule.xml_module import XmlDescriptor
import unittest import unittest
from .import system_test from .import get_test_system
from mock import Mock from mock import Mock
...@@ -139,7 +139,7 @@ class EditableMetadataFieldsTest(unittest.TestCase): ...@@ -139,7 +139,7 @@ class EditableMetadataFieldsTest(unittest.TestCase):
# Start of helper methods # Start of helper methods
def get_xml_editable_fields(self, model_data): def get_xml_editable_fields(self, model_data):
system = system_test() system = get_test_system()
system.render_template = Mock(return_value="<div>Test Template HTML</div>") system.render_template = Mock(return_value="<div>Test Template HTML</div>")
return XmlDescriptor(system=system, location=None, model_data=model_data).editable_metadata_fields return XmlDescriptor(system=system, location=None, model_data=model_data).editable_metadata_fields
...@@ -151,7 +151,7 @@ class EditableMetadataFieldsTest(unittest.TestCase): ...@@ -151,7 +151,7 @@ class EditableMetadataFieldsTest(unittest.TestCase):
non_editable_fields.append(TestModuleDescriptor.due) non_editable_fields.append(TestModuleDescriptor.due)
return non_editable_fields return non_editable_fields
system = system_test() system = get_test_system()
system.render_template = Mock(return_value="<div>Test Template HTML</div>") system.render_template = Mock(return_value="<div>Test Template HTML</div>")
return TestModuleDescriptor(system=system, location=None, model_data=model_data) return TestModuleDescriptor(system=system, location=None, model_data=model_data)
......
...@@ -13,7 +13,7 @@ from django.test.client import Client ...@@ -13,7 +13,7 @@ from django.test.client import Client
from student.tests.factories import UserFactory, CourseEnrollmentFactory from student.tests.factories import UserFactory, CourseEnrollmentFactory
from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE
from xmodule.tests import system_test from xmodule.tests import get_test_system
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
...@@ -78,7 +78,7 @@ class BaseTestXmodule(ModuleStoreTestCase): ...@@ -78,7 +78,7 @@ class BaseTestXmodule(ModuleStoreTestCase):
) )
location = self.item_descriptor.location location = self.item_descriptor.location
system = system_test() system = get_test_system()
system.render_template = lambda template, context: context system.render_template = lambda template, context: context
self.item_module = self.item_descriptor.module_class( self.item_module = self.item_descriptor.module_class(
......
...@@ -20,7 +20,7 @@ from lxml import etree ...@@ -20,7 +20,7 @@ from lxml import etree
from xmodule.video_module import VideoDescriptor, VideoModule from xmodule.video_module import VideoDescriptor, VideoModule
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.tests import system_test from xmodule.tests import get_test_system
from xmodule.tests.test_logic import LogicTest from xmodule.tests.test_logic import LogicTest
...@@ -51,7 +51,7 @@ class VideoFactory(object): ...@@ -51,7 +51,7 @@ class VideoFactory(object):
descriptor = Mock(weight="1") descriptor = Mock(weight="1")
system = system_test() system = get_test_system()
system.render_template = lambda template, context: context system.render_template = lambda template, context: context
module = VideoModule(system, location, descriptor, model_data) module = VideoModule(system, location, descriptor, model_data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment