Exemplo n.º 1
0
 def test_dict_roundtrip(self):
     q1 = Quiz(description="first", show_submit_state=False)
     d = q1.as_dict()
     q2 = Quiz(description="second")
     q2.import_from_dict(d)
     self.assertEquals(q2.description, "first")
     self.assertEquals(q1.allow_redo, q2.allow_redo)
     self.assertEquals(q1.rhetorical, q2.rhetorical)
     self.assertEquals(q1.show_submit_state, q2.show_submit_state)
Exemplo n.º 2
0
 def test_import_from_dict_defaults(self):
     d = {
         'description': 'Test Quiz',
     }
     q = Quiz()
     q.import_from_dict(d)
     self.assertEqual(q.description, 'Test Quiz')
     self.assertEqual(q.allow_redo, True)
     self.assertEqual(q.rhetorical, False)
     self.assertEqual(q.show_submit_state, True)
     self.assertEqual(q.submission_set.count(), 0)
     self.assertEqual(q.question_set.count(), 0)
Exemplo n.º 3
0
 def test_import_from_dict_defaults_2(self):
     d = {
         'description': 'Test Quiz',
         'rhetorical': False,
         'allow_redo': False,
         'show_submit_state': True,
         'questions': [{
             'text': 'Test Question',
             'question_type': 'single choice',
             'explanation': '',
             'answers': [],
         }],
     }
     q = Quiz()
     q.import_from_dict(d)
     self.assertEqual(q.description, 'Test Quiz')
     self.assertEqual(q.allow_redo, False)
     self.assertEqual(q.rhetorical, False)
     self.assertEqual(q.show_submit_state, True)
     self.assertEqual(q.submission_set.count(), 0)
     self.assertEqual(q.question_set.count(), 1)
     self.assertEqual(q.question_set.first().intro_text, '')