Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

test_views.py 919B

12345678910111213141516171819202122232425262728
  1. from unittest.mock import Mock, patch
  2. from django.test import Client, TestCase
  3. from django.urls import reverse
  4. from oscar.apps.customer.forms import EmailAuthenticationForm
  5. class TestAccountAuthView(TestCase):
  6. def setUp(self):
  7. self.client = Client()
  8. def test_request_is_passed_to_form(self):
  9. form_class = Mock(wraps=EmailAuthenticationForm)
  10. data = {"login_submit": ["1"]}
  11. initial = {'redirect_url': ''}
  12. with patch("oscar.apps.customer.views.AccountAuthView.login_form_class", new=form_class):
  13. response = self.client.post(reverse("customer:login"), data=data)
  14. assert form_class.called
  15. form_class.assert_called_with(
  16. data=data,
  17. files={},
  18. host="testserver",
  19. initial=initial,
  20. prefix='login',
  21. request=response.wsgi_request,
  22. )