From bb0601ff7a36e02a0928ed0f2220c3379c365fc0 Mon Sep 17 00:00:00 2001 From: kimth <kimt@mit.edu> Date: Wed, 18 Jul 2012 08:54:54 -0400 Subject: [PATCH] Further tests of CorrectMap in CodeResponse unit testing --- common/lib/xmodule/tests/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/tests/__init__.py b/common/lib/xmodule/tests/__init__.py index 2f12c96..09c533e 100644 --- a/common/lib/xmodule/tests/__init__.py +++ b/common/lib/xmodule/tests/__init__.py @@ -281,7 +281,7 @@ class CodeResponseTest(unittest.TestCase): problem_file = os.path.dirname(__file__)+"/test_files/coderesponse.xml" test_lcp = lcp.LoncapaProblem(open(problem_file).read(), '1', system=i4xs) - # CodeResponse requires internal CorrectMap state. Build it now + # CodeResponse requires internal CorrectMap state. Build it now in the 'queued' state old_cmap = CorrectMap() answer_ids = sorted(test_lcp.get_question_answers().keys()) numAnswers = len(answer_ids) @@ -303,6 +303,9 @@ class CodeResponseTest(unittest.TestCase): test_lcp.update_score(xserver_msgs[correctness], queuekey=0) self.assertEquals(test_lcp.correct_map.get_dict(), old_cmap.get_dict()) # Deep comparison + for i in range(numAnswers): + self.assertTrue(test_lcp.correct_map.is_queued(answer_ids[i])) # Should be still queued, since message undelivered + # Correct queuekey, state should be updated for correctness in ['correct', 'incorrect']: for i in range(numAnswers): # Target specific answer_id's @@ -316,6 +319,12 @@ class CodeResponseTest(unittest.TestCase): test_lcp.update_score(xserver_msgs[correctness], queuekey=1000+i) self.assertEquals(test_lcp.correct_map.get_dict(), new_cmap.get_dict()) + for j in range(numAnswers): + if j == i: + self.assertFalse(test_lcp.correct_map.is_queued(answer_ids[j])) # Should be dequeued, message delivered + else: + self.assertTrue(test_lcp.correct_map.is_queued(answer_ids[j])) # Should be queued, message undelivered + #----------------------------------------------------------------------------- # Grading tests -- libgit2 0.26.0