Add test for proper saving

This commit is contained in:
Vik Paruchuri
2013-05-09 10:05:48 -04:00
parent 7a1ef62ee3
commit f9e97cb935
4 changed files with 32 additions and 6 deletions

View File

@@ -496,6 +496,7 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
self.test_system.xqueue['interface'] = Mock(
send_to_queue=Mock(side_effect=[1, "queued"])
)
self.setup_modulestore(COURSE)
def test_open_ended_load_and_save(self):
"""
@@ -510,6 +511,10 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
task_one_json = json.loads(module.task_states[0])
self.assertEqual(task_one_json['child_history'][0]['answer'], self.answer)
module = self.get_module_from_location(self.problem_location, COURSE)
task_one_json = json.loads(module.task_states[0])
self.assertEqual(task_one_json['child_history'][0]['answer'], self.answer)
def test_open_ended_flow_reset(self):
"""
Test the flow of the module if we complete the self assessment step and then reset

View File

@@ -40,6 +40,7 @@ class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
"""
self.test_system = 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)
def test_module_closed(self):
@@ -129,4 +130,24 @@ class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
Get the instance state dict
@return:
"""
self.peer_grading.get_instance_state()
self.peer_grading.get_instance_state()
class PeerGradingModuleScoredTest(unittest.TestCase, DummyModulestore):
"""
Test peer grading xmodule at the unit level. More detailed tests are difficult, as the module relies on an
external grading service.
"""
problem_location = Location(["i4x", "edX", "open_ended", "peergrading",
"PeerGradingScored"])
def setUp(self):
"""
Create a peer grading module from a test system
@return:
"""
self.test_system = test_system()
self.test_system.open_ended_grading_interface = None
self.setup_modulestore(COURSE)
def test_metadata_load(self):
peer_grading = self.get_module_from_location(self.problem_location, COURSE)
self.assertEqual(peer_grading.closed(), False)

View File

@@ -38,12 +38,12 @@ class DummyModulestore(object):
"""
test_system = test_system()
def setup_modulestore(self, name):
self.modulestore = XMLModuleStore(DATA_DIR, course_dirs=[name])
def get_course(self, name):
"""Get a test course by directory name. If there's more than one, error."""
modulestore = XMLModuleStore(DATA_DIR, course_dirs=[name])
courses = modulestore.get_courses()
self.modulestore = modulestore
courses = self.modulestore.get_courses()
return courses[0]
def get_module_from_location(self, location, course):

View File

@@ -1 +1 @@
<peergrading is_graded="True" max_grade="1" use_for_single_location="True" link_to_location="i4x://edX/open_ended/combinedopenended/SampleQuestion"/>
<peergrading is_graded="True" max_grade="1" use_for_single_location="False" link_to_location="i4x://edX/open_ended/combinedopenended/SampleQuestion"/>