Beispiel #1
0
    def test_get_answer_options(self):
        view = views.QuestionView()
        get_answer_options = view.get_answer_options

        self.assertIn('yes', dict(get_answer_options()))
        self.assertIn('no', dict(get_answer_options()))

        view.answer_options = [('new_answer', 'Answer')]
        self.assertNotIn('yes', dict(get_answer_options()))
        self.assertIn('new_answer', dict(get_answer_options()))
Beispiel #2
0
    def test_get_question_message(self):
        view = views.QuestionView()
        get_question_message = view.get_question_message

        self.assertEqual(get_question_message(), 'Are you sure?')

        view.question_message = 'new_question'
        self.assertEqual(get_question_message(), 'new_question')

        self.assertIsInstance(get_question_message(), str)
Beispiel #3
0
    def test_get_question_message(self):
        view = views.QuestionView()
        get_question_message = view.get_question_message

        self.assertEqual(get_question_message(), 'Are you sure?')

        view.question_message = 'new_question'
        self.assertEqual(get_question_message(), 'new_question')

        # Make sure it is unicode, so ugettext_lazy can work
        self.assertIsInstance(get_question_message(), unicode)
Beispiel #4
0
    def test_get_redirect_url(self):
        view = views.QuestionView()
        get_redirect_url = view.get_redirect_url

        view.request = self.rf.get('/')
        view.question_url = 'redirect_to_get_url'
        self.assertEqual(get_redirect_url(), 'redirect_to_get_url')

        view.request = self.rf.post('/')
        view.url = 'redirect_to_post_url'
        self.assertEqual(get_redirect_url(), 'redirect_to_post_url')
Beispiel #5
0
    def test_confirm_form(self, mock_messages):
        view = views.QuestionView()
        view.question_message = 'the question'
        confirm_form = view.confirm_form
        view.request = self.rf.get('/')

        confirm_form()

        self.assertTrue(mock_messages.warning.called)

        question = mock_messages.warning.call_args[0][1]
        self.assertIn('the question', question)