Ejemplo n.º 1
0
 def test_answer_is_among_options(self):
     question = get_question()
     test = []
     for option in get_options(question):
         q = db.session.query(Answer).filter(Answer.description == str(option)).first()
         test.append(q.question_id)
     self.assertTrue(question.question_id in test)
    def test_get_question(self):

        expected = 'What\'s your question? '
        with patch('builtins.input') as mocked_input, patch(
                'builtins.print') as mocked_print:
            mocked_input.side_effect = ('', 'Will I be rich and famous?')
            question = app.get_question()
            mocked_print.assert_called_with('A valid input is required')
            mocked_input.assert_called_with(expected)
            self.assertEqual(question, 'Will I be rich and famous?')
Ejemplo n.º 3
0
 def test_answer_list_is_unique(self):
     question = get_question()
     self.assertEqual(len(set(get_options(question))),3)