Esempio n. 1
0
 def testQuestionChoiceInsert(self):
     survey_id = connection.execute(
         survey_table.select().where(
             survey_table.c.survey_title == 'test_title'
         )).first().survey_id
     seq_number = get_free_sequence_number(connection, survey_id)
     stmt = question_insert(hint=None, allow_multiple=None,
                            logic={
                                'required': False,
                                'allow_other': False,
                                'allow_dont_know': False
                            },
                            sequence_number=seq_number,
                            question_title='test choice',
                            type_constraint_name='multiple_choice',
                            question_to_sequence_number=-1,
                            survey_id=survey_id)
     question_id = connection.execute(stmt).inserted_primary_key[0]
     c_stmt = question_choice_insert(question_id=question_id,
                                     choice='test choice',
                                     choice_number=1,
                                     type_constraint_name='multiple_choice',
                                     question_sequence_number=seq_number,
                                     allow_multiple=False,
                                     survey_id=survey_id)
     choice_id = connection.execute(c_stmt).inserted_primary_key[0]
     cond = question_choice_table.c.question_id == question_id
     self.assertEqual(connection.execute(
         question_choice_table.select().where(cond)
     ).first().question_choice_id, choice_id)
Esempio n. 2
0
 def testNoLogic(self):
     survey_id = connection.execute(survey_table.select().where(
         survey_table.c.survey_title == 'test_title')).first().survey_id
     sequence_number = get_free_sequence_number(connection,
                                                survey_id)
     with self.assertRaises(TypeError) as exc:
         question_insert(hint=None,
                         allow_multiple=None,
                         logic=None,
                         sequence_number=sequence_number,
                         question_to_sequence_number=1,
                         question_title='test insert',
                         type_constraint_name='text',
                         survey_id=survey_id)
     self.assertEqual(str(exc.exception), 'logic must not be None')
Esempio n. 3
0
 def testGetFreeSequenceNumber(self):
     survey_id = connection.execute(survey_table.select().where(
         survey_table.c.survey_title == 'test_title')).first().survey_id
     self.assertEqual(
         get_free_sequence_number(connection, survey_id),
         11)