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