def test_success_url_as_url(self, get_context_data):
        url = '/account/two_factor/'
        view = PhoneSetupView()
        view.success_url = url

        def return_kwargs(form, **kwargs):
            return kwargs
        get_context_data.side_effect = return_kwargs

        context = view.get_context_data(None)
        self.assertIn('cancel_url', context)
        self.assertEqual(url, context['cancel_url'])
Esempio n. 2
0
    def test_success_url_as_url(self, get_context_data):
        url = '/account/two_factor/'
        view = PhoneSetupView()
        view.success_url = url

        def return_kwargs(form, **kwargs):
            return kwargs
        get_context_data.side_effect = return_kwargs

        context = view.get_context_data(None)
        self.assertIn('cancel_url', context)
        self.assertEqual(url, context['cancel_url'])
    def test_success_url_as_reverse_lazy(self, get_context_data):
        url_name = 'two_factor:profile'
        url = reverse(url_name)
        view = PhoneSetupView()
        view.success_url = reverse_lazy(url_name)

        def return_kwargs(form, **kwargs):
            return kwargs
        get_context_data.side_effect = return_kwargs

        context = view.get_context_data(None)
        self.assertIn('cancel_url', context)
        self.assertEqual(url, context['cancel_url'])
Esempio n. 4
0
    def test_success_url_as_named_url(self, get_context_data):
        url_name = 'two_factor:profile'
        url = reverse(url_name)
        view = PhoneSetupView()
        view.success_url = url_name

        def return_kwargs(form, **kwargs):
            return kwargs
        get_context_data.side_effect = return_kwargs

        context = view.get_context_data(None)
        self.assertIn('cancel_url', context)
        self.assertEqual(url, context['cancel_url'])