Renames self.get_test_system to test_system, removes duplicate function.
This commit is contained in:
@@ -68,8 +68,8 @@ class OpenEndedChildTest(unittest.TestCase):
|
||||
descriptor = Mock()
|
||||
|
||||
def setUp(self):
|
||||
self.get_test_system = get_test_system()
|
||||
self.openendedchild = OpenEndedChild(self.get_test_system, self.location,
|
||||
self.test_system = get_test_system()
|
||||
self.openendedchild = OpenEndedChild(self.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.get_test_system)
|
||||
answer = self.openendedchild.latest_post_assessment(self.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.get_test_system))
|
||||
self.openendedchild.latest_post_assessment(self.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.get_test_system)
|
||||
self.openendedchild.reset(self.test_system)
|
||||
state = json.loads(self.openendedchild.get_instance_state())
|
||||
self.assertEqual(state['child_state'], OpenEndedChild.INITIAL)
|
||||
|
||||
@@ -192,19 +192,19 @@ class OpenEndedModuleTest(unittest.TestCase):
|
||||
descriptor = Mock()
|
||||
|
||||
def setUp(self):
|
||||
self.get_test_system = get_test_system()
|
||||
self.test_system = get_test_system()
|
||||
|
||||
self.get_test_system.location = self.location
|
||||
self.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.get_test_system.xqueue = {'interface': self.mock_xqueue, 'construct_callback': constructed_callback,
|
||||
self.test_system.xqueue = {'interface': self.mock_xqueue, 'construct_callback': constructed_callback,
|
||||
'default_queuename': 'testqueue',
|
||||
'waittime': 1}
|
||||
self.openendedmodule = OpenEndedModule(self.get_test_system, self.location,
|
||||
self.openendedmodule = OpenEndedModule(self.test_system, self.location,
|
||||
self.definition, self.descriptor, self.static_data, self.metadata)
|
||||
|
||||
def test_message_post(self):
|
||||
@@ -213,7 +213,7 @@ class OpenEndedModuleTest(unittest.TestCase):
|
||||
'grader_id': '1',
|
||||
'score': 3}
|
||||
qtime = datetime.strftime(datetime.now(), xqueue_interface.dateformat)
|
||||
student_info = {'anonymous_student_id': self.get_test_system.anonymous_student_id,
|
||||
student_info = {'anonymous_student_id': self.test_system.anonymous_student_id,
|
||||
'submission_time': qtime}
|
||||
contents = {
|
||||
'feedback': get['feedback'],
|
||||
@@ -223,7 +223,7 @@ class OpenEndedModuleTest(unittest.TestCase):
|
||||
'student_info': json.dumps(student_info)
|
||||
}
|
||||
|
||||
result = self.openendedmodule.message_post(get, self.get_test_system)
|
||||
result = self.openendedmodule.message_post(get, self.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)
|
||||
@@ -234,7 +234,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.get_test_system.anonymous_student_id,
|
||||
student_info = {'anonymous_student_id': self.test_system.anonymous_student_id,
|
||||
'submission_time': qtime}
|
||||
contents = self.openendedmodule.payload.copy()
|
||||
contents.update({
|
||||
@@ -242,7 +242,7 @@ class OpenEndedModuleTest(unittest.TestCase):
|
||||
'student_response': submission,
|
||||
'max_score': self.max_score
|
||||
})
|
||||
result = self.openendedmodule.send_to_grader(submission, self.get_test_system)
|
||||
result = self.openendedmodule.send_to_grader(submission, self.test_system)
|
||||
self.assertTrue(result)
|
||||
self.mock_xqueue.send_to_queue.assert_called_with(body=json.dumps(contents), header=ANY)
|
||||
|
||||
@@ -256,7 +256,7 @@ class OpenEndedModuleTest(unittest.TestCase):
|
||||
}
|
||||
get = {'queuekey': "abcd",
|
||||
'xqueue_body': score_msg}
|
||||
self.openendedmodule.update_score(get, self.get_test_system)
|
||||
self.openendedmodule.update_score(get, self.test_system)
|
||||
|
||||
def update_score_single(self):
|
||||
self.openendedmodule.new_history_entry("New Entry")
|
||||
@@ -279,11 +279,11 @@ class OpenEndedModuleTest(unittest.TestCase):
|
||||
}
|
||||
get = {'queuekey': "abcd",
|
||||
'xqueue_body': json.dumps(score_msg)}
|
||||
self.openendedmodule.update_score(get, self.get_test_system)
|
||||
self.openendedmodule.update_score(get, self.test_system)
|
||||
|
||||
def test_latest_post_assessment(self):
|
||||
self.update_score_single()
|
||||
assessment = self.openendedmodule.latest_post_assessment(self.get_test_system)
|
||||
assessment = self.openendedmodule.latest_post_assessment(self.test_system)
|
||||
self.assertFalse(assessment == '')
|
||||
# check for errors
|
||||
self.assertFalse('errors' in assessment)
|
||||
@@ -367,9 +367,9 @@ 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)
|
||||
get_test_system = get_test_system()
|
||||
test_system = get_test_system()
|
||||
combinedoe_container = CombinedOpenEndedModule(
|
||||
get_test_system,
|
||||
test_system,
|
||||
descriptor,
|
||||
model_data={
|
||||
'data': full_definition,
|
||||
@@ -381,7 +381,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.get_test_system,
|
||||
self.combinedoe = CombinedOpenEndedV1Module(self.test_system,
|
||||
self.location,
|
||||
self.definition,
|
||||
self.descriptor,
|
||||
@@ -441,7 +441,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.get_test_system,
|
||||
combinedoe = CombinedOpenEndedV1Module(self.test_system,
|
||||
self.location,
|
||||
definition,
|
||||
descriptor,
|
||||
@@ -471,7 +471,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.get_test_system,
|
||||
combinedoe = CombinedOpenEndedV1Module(self.test_system,
|
||||
self.location,
|
||||
definition,
|
||||
descriptor,
|
||||
@@ -493,8 +493,8 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
|
||||
hint = "blah"
|
||||
|
||||
def setUp(self):
|
||||
self.get_test_system = get_test_system()
|
||||
self.get_test_system.xqueue['interface'] = Mock(
|
||||
self.test_system = get_test_system()
|
||||
self.test_system.xqueue['interface'] = Mock(
|
||||
send_to_queue=Mock(side_effect=[1, "queued"])
|
||||
)
|
||||
self.setup_modulestore(COURSE)
|
||||
@@ -569,6 +569,7 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
|
||||
#Mock a student submitting an assessment
|
||||
assessment_dict = MockQueryDict()
|
||||
assessment_dict.update({'assessment': sum(assessment), 'score_list[]': assessment})
|
||||
#from nose.tools import set_trace; set_trace()
|
||||
module.handle_ajax("save_assessment", assessment_dict)
|
||||
task_one_json = json.loads(module.task_states[0])
|
||||
self.assertEqual(json.loads(task_one_json['child_history'][0]['post_assessment']), assessment)
|
||||
|
||||
@@ -103,11 +103,11 @@ class ConditionalModuleBasicTest(unittest.TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.get_test_system = get_test_system()
|
||||
self.test_system = get_test_system()
|
||||
|
||||
def test_icon_class(self):
|
||||
'''verify that get_icon_class works independent of condition satisfaction'''
|
||||
modules = ConditionalFactory.create(self.get_test_system)
|
||||
modules = ConditionalFactory.create(self.test_system)
|
||||
for attempted in ["false", "true"]:
|
||||
for icon_class in [ 'other', 'problem', 'video']:
|
||||
modules['source_module'].is_attempted = attempted
|
||||
@@ -116,7 +116,7 @@ class ConditionalModuleBasicTest(unittest.TestCase):
|
||||
|
||||
|
||||
def test_get_html(self):
|
||||
modules = ConditionalFactory.create(self.get_test_system)
|
||||
modules = ConditionalFactory.create(self.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()
|
||||
@@ -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.get_test_system)
|
||||
modules = ConditionalFactory.create(self.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.get_test_system, source_is_error_module=True)
|
||||
modules = ConditionalFactory.create(self.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.get_test_system = get_test_system()
|
||||
self.test_system = get_test_system()
|
||||
|
||||
def get_course(self, name):
|
||||
"""Get a test course by directory name. If there's more than one, error."""
|
||||
@@ -186,7 +186,7 @@ class ConditionalModuleXmlTest(unittest.TestCase):
|
||||
if isinstance(descriptor, Location):
|
||||
location = descriptor
|
||||
descriptor = self.modulestore.get_instance(course.id, location, depth=None)
|
||||
return descriptor.xmodule(self.get_test_system)
|
||||
return descriptor.xmodule(self.test_system)
|
||||
|
||||
# edx - HarvardX
|
||||
# cond_test - ER22x
|
||||
@@ -194,8 +194,8 @@ class ConditionalModuleXmlTest(unittest.TestCase):
|
||||
|
||||
def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/', course_namespace=None):
|
||||
return text
|
||||
self.get_test_system.replace_urls = replace_urls
|
||||
self.get_test_system.get_module = inner_get_module
|
||||
self.test_system.replace_urls = replace_urls
|
||||
self.test_system.get_module = inner_get_module
|
||||
|
||||
module = inner_get_module(location)
|
||||
print "module: ", module
|
||||
|
||||
@@ -9,10 +9,7 @@ from xmodule.x_module import XModuleDescriptor
|
||||
from mock import MagicMock
|
||||
|
||||
|
||||
class TestErrorModule(unittest.TestCase):
|
||||
"""
|
||||
Tests for ErrorModule and ErrorDescriptor
|
||||
"""
|
||||
class SetupTestErrorModules():
|
||||
def setUp(self):
|
||||
self.system = get_test_system()
|
||||
self.org = "org"
|
||||
@@ -21,6 +18,14 @@ class TestErrorModule(unittest.TestCase):
|
||||
self.valid_xml = u"<problem>ABC \N{SNOWMAN}</problem>"
|
||||
self.error_msg = "Error"
|
||||
|
||||
|
||||
class TestErrorModule(unittest.TestCase, SetupTestErrorModules):
|
||||
"""
|
||||
Tests for ErrorModule and ErrorDescriptor
|
||||
"""
|
||||
def setUp(self):
|
||||
SetupTestErrorModules.setUp(self)
|
||||
|
||||
def test_error_module_xml_rendering(self):
|
||||
descriptor = error_module.ErrorDescriptor.from_xml(
|
||||
self.valid_xml, self.system, self.org, self.course, self.error_msg)
|
||||
@@ -45,17 +50,12 @@ class TestErrorModule(unittest.TestCase):
|
||||
self.assertIn(repr(descriptor), context_repr)
|
||||
|
||||
|
||||
class TestNonStaffErrorModule(unittest.TestCase):
|
||||
class TestNonStaffErrorModule(unittest.TestCase, SetupTestErrorModules):
|
||||
"""
|
||||
Tests for NonStaffErrorModule and NonStaffErrorDescriptor
|
||||
"""
|
||||
def setUp(self):
|
||||
self.system = get_test_system()
|
||||
self.org = "org"
|
||||
self.course = "course"
|
||||
self.location = Location(['i4x', self.org, self.course, None, None])
|
||||
self.valid_xml = u"<problem>ABC \N{SNOWMAN}</problem>"
|
||||
self.error_msg = "Error"
|
||||
SetupTestErrorModules.setUp(self)
|
||||
|
||||
def test_non_staff_error_module_create(self):
|
||||
descriptor = error_module.NonStaffErrorDescriptor.from_xml(
|
||||
|
||||
@@ -39,8 +39,8 @@ class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
|
||||
Create a peer grading module from a test system
|
||||
@return:
|
||||
"""
|
||||
self.get_test_system = get_test_system()
|
||||
self.get_test_system.open_ended_grading_interface = None
|
||||
self.test_system = get_test_system()
|
||||
self.test_system.open_ended_grading_interface = None
|
||||
self.setup_modulestore(COURSE)
|
||||
self.peer_grading = self.get_module_from_location(self.problem_location, COURSE)
|
||||
|
||||
@@ -151,8 +151,8 @@ class PeerGradingModuleScoredTest(unittest.TestCase, DummyModulestore):
|
||||
Create a peer grading module from a test system
|
||||
@return:
|
||||
"""
|
||||
self.get_test_system = get_test_system()
|
||||
self.get_test_system.open_ended_grading_interface = None
|
||||
self.test_system = get_test_system()
|
||||
self.test_system.open_ended_grading_interface = None
|
||||
self.setup_modulestore(COURSE)
|
||||
|
||||
def test_metadata_load(self):
|
||||
|
||||
@@ -52,4 +52,4 @@ class DummyModulestore(object):
|
||||
if not isinstance(location, Location):
|
||||
location = Location(location)
|
||||
descriptor = self.modulestore.get_instance(course.id, location, depth=None)
|
||||
return descriptor.xmodule(self.get_test_system)
|
||||
return descriptor.xmodule(self.test_system)
|
||||
|
||||
Reference in New Issue
Block a user