Ejemplo n.º 1
0
 def test_option_type_templates(self):
     outcomes = ["oink", "oink2"]
     for i in range(len(self.option_types)):
         t = self.option_types[i]
         qtext = RealityCheckQuestion.encodeText(t, 'oink', outcomes, 'my-category')
         q = RealityCheckQuestion.populatedJSONForTemplate(RealityCheckTemplate.defaultTemplateForType(t), qtext)
         self.assertEqual(q['type'], t)
Ejemplo n.º 2
0
 def test_multiple_selects(self):
     outcomes = ['thing1', 'thing2', 'thing3']
     qtext = RealityCheckQuestion.encodeText('multiple-select', 'oink', outcomes, 'my-category')
     q = RealityCheckQuestion.populatedJSONForTemplate(RealityCheckTemplate.defaultTemplateForType('multiple-select'), qtext)
     self.assertEqual(RealityCheckQuestion.getAnswerString(q, '0x0000000000000000000000000000000000000000000000000000000000000000'), '')
     self.assertEqual(RealityCheckQuestion.getAnswerString(q, '0x0000000000000000000000000000000000000000000000000000000000000005'), 'thing1 / thing3')
     self.assertEqual(RealityCheckQuestion.getAnswerString(q, '0x0000000000000000000000000000000000000000000000000000000000000002'), 'thing2')
     self.assertEqual(RealityCheckQuestion.getAnswerString(q, '0x0000000000000000000000000000000000000000000000000000000000000003'), 'thing1 / thing2')
Ejemplo n.º 3
0
 def test_option_hexification(self):
     outcomes = ['thing1', 'thing2', 'thing3']
     qtext = RealityCheckQuestion.encodeText('multiple-select', 'oink', outcomes, 'my-category')
     q = RealityCheckQuestion.populatedJSONForTemplate(RealityCheckTemplate.defaultTemplateForType('multiple-select'), qtext)
     self.assertEqual(q['type'], 'multiple-select')
     
     self.assertEqual(RealityCheckQuestion.answerToBytes32([False], q), '0x0000000000000000000000000000000000000000000000000000000000000000')
     self.assertEqual(RealityCheckQuestion.answerToBytes32([False, False], q), '0x0000000000000000000000000000000000000000000000000000000000000000')
     self.assertEqual(RealityCheckQuestion.answerToBytes32([True], q), '0x0000000000000000000000000000000000000000000000000000000000000001')
     self.assertEqual(RealityCheckQuestion.answerToBytes32([True, False], q), '0x0000000000000000000000000000000000000000000000000000000000000001')
     self.assertEqual(RealityCheckQuestion.answerToBytes32([False, True], q), '0x0000000000000000000000000000000000000000000000000000000000000002')
     self.assertEqual(RealityCheckQuestion.answerToBytes32([True, True], q), '0x0000000000000000000000000000000000000000000000000000000000000003')
     self.assertEqual(RealityCheckQuestion.answerToBytes32([True, False, True], q), '0x0000000000000000000000000000000000000000000000000000000000000005')
Ejemplo n.º 4
0
 def test_simple_type_templates(self):
     for i in range(len(self.simple_types)):
         t = self.simple_types[i]
         qtext = RealityCheckQuestion.encodeText(t, 'oink', None, 'my-category')
         q = RealityCheckQuestion.populatedJSONForTemplate(RealityCheckTemplate.defaultTemplateForType(t), qtext)
         self.assertEqual(q['type'], t)
Ejemplo n.º 5
0
 def test_unparseable_questions(self):
     qtext = RealityCheckQuestion.encodeText('bool', 'Is the name of the game "The Name of the Game"?', None, 'my-category')
     # mangle the quotation marks as if we did the encoding wrong
     qtext = qtext.replace('\\"', '"')
     q = RealityCheckQuestion.populatedJSONForTemplate(RealityCheckTemplate.defaultTemplateForType('bool'), qtext)
     self.assertEqual(q['type'], 'broken-question')