Ejemplo n.º 1
0
    def test_create_question(self):

        question = Question()

        data = {
            'questionText': 'Example text',
            'multi': 'false',
            'options': ['yes', 'no'],
            'text': 'false',
            'mandatory': 'true'
        }

        question.load_from_dict(data)

        write_id = question.write_to_db(DATABASE_FILENAME)

        question = None

        question = Question()
        question.load_from_db(DATABASE_FILENAME, write_id)

        self.assertEqual(question.get_id(), write_id)
        self.assertEqual(question.get_question_text(), 'Example text')
        self.assertEqual(question.get_type(), 'single')
        self.assertEqual(question.get_mandatory(), True)
        self.assertEqual(question.get_options()[0], 'yes')
Ejemplo n.º 2
0
    def test_values_read_from_dictionary(self):

        question = Question()

        data = {
            'questionNum': 20,
            'questionText': 'Example text',
            'multi': 'false',
            'options': ['yes', 'no'],
            'text': 'false',
            'mandatory': 'true'
        }

        question.load_from_dict(data)

        self.assertEqual(question.get_id(), 20)
        self.assertEqual(question.get_question_text(), 'Example text')
        self.assertEqual(question.get_type(), 'single')
        self.assertEqual(question.get_mandatory(), True)
        self.assertEqual(question.get_options()[0], 'yes')