@@ -232,7 +232,7 @@ So let's call `send_mail`, naively:
232
232
233
233
234
234
[role="sourcecode"]
235
- .src/accounts/views.py
235
+ .src/accounts/views.py (ch19l006-1)
236
236
====
237
237
[source,python]
238
238
----
@@ -259,7 +259,7 @@ Let's try this:
259
259
260
260
261
261
[role="sourcecode"]
262
- .src/accounts/views.py
262
+ .src/accounts/views.py (ch19l006-2)
263
263
====
264
264
[source,python]
265
265
----
@@ -281,7 +281,7 @@ something like this:
281
281
282
282
283
283
[role="sourcecode"]
284
- .src/accounts/views.py
284
+ .src/accounts/views.py (ch19l006)
285
285
====
286
286
[source,python]
287
287
----
@@ -512,8 +512,8 @@ First let's get back to our FT and see where it's failing:
512
512
----
513
513
$ pass:quotes[*python src/manage.py test functional_tests.test_login*]
514
514
[...]
515
- AssertionError: 'Check your email' not found in 'Superlists\nEnter email to log
516
- in: \nStart a new To-Do list'
515
+ AssertionError: 'Check your email' not found in 'Superlists\nEnter your email
516
+ to log in \nStart a new To-Do list'
517
517
----
518
518
519
519
Submitting the email address currently has no effect,
@@ -586,7 +586,7 @@ And we can get it passing with:
586
586
587
587
588
588
[role="sourcecode"]
589
- .src/accounts/views.py (ch17l014 )
589
+ .src/accounts/views.py (ch19l014 )
590
590
====
591
591
[source,python]
592
592
----
@@ -597,7 +597,7 @@ def send_login_email(request):
597
597
[...]
598
598
messages.success(
599
599
request,
600
- "Check your email, we've sent you a link you can use to log in."
600
+ "Check your email, we've sent you a link you can use to log in.",
601
601
)
602
602
return redirect("/")
603
603
----
@@ -653,7 +653,7 @@ achieve the same result. I could write the code like this:
653
653
messages.add_message(
654
654
request,
655
655
messages.SUCCESS,
656
- "Check your email, we've sent you a link you can use to log in."
656
+ "Check your email, we've sent you a link you can use to log in.",
657
657
)
658
658
----
659
659
====
@@ -730,15 +730,15 @@ Let's just cheat for now though, by changing the value in the view:
730
730
731
731
732
732
[role="sourcecode"]
733
- .src/accounts/views.py
733
+ .src/accounts/views.py (ch19l016)
734
734
====
735
735
[source,python]
736
736
----
737
737
send_mail(
738
- ' Your login link for Superlists' ,
739
- ' Use this link to log in' ,
740
- ' noreply@superlists' ,
741
- [email]
738
+ " Your login link for Superlists" ,
739
+ " Use this link to log in" ,
740
+ " noreply@superlists" ,
741
+ [email],
742
742
)
743
743
----
744
744
====
@@ -763,15 +763,14 @@ just cheats:
763
763
764
764
765
765
[role="sourcecode"]
766
- .src/accounts/tests/test_views.py (ch17l017 )
766
+ .src/accounts/tests/test_views.py (ch19l017 )
767
767
====
768
768
[source,python]
769
769
----
770
770
class LoginViewTest(TestCase):
771
-
772
771
def test_redirects_to_home_page(self):
773
- response = self.client.get(' /accounts/login?token=abcd123' )
774
- self.assertRedirects(response, '/' )
772
+ response = self.client.get(" /accounts/login?token=abcd123" )
773
+ self.assertRedirects(response, "/" )
775
774
----
776
775
====
777
776
@@ -793,7 +792,7 @@ code was 404 (expected 302)
793
792
794
793
* No view:
795
794
+
796
- [role="dofirst-ch17l018 small-code"]
795
+ [role="dofirst-ch19l018 small-code"]
797
796
----
798
797
AttributeError: module 'accounts.views' has no attribute 'login'
799
798
----
@@ -894,7 +893,7 @@ from accounts.models import Token
894
893
[...]
895
894
896
895
def send_login_email(request):
897
- email = request.POST[' email' ]
896
+ email = request.POST[" email" ]
898
897
token = Token.objects.create(email=email)
899
898
send_mail(
900
899
[...]
@@ -904,7 +903,7 @@ def send_login_email(request):
904
903
And now the second test prompts us to actually use the token in the body
905
904
of our email:
906
905
907
- [subs="specialcharacters,macros "]
906
+ [subs=""]
908
907
----
909
908
[...]
910
909
AssertionError:
@@ -918,7 +917,7 @@ So we can insert the token into our email like this:
918
917
919
918
920
919
[role="sourcecode"]
921
- .src/accounts/views.py (ch19l023 )
920
+ .src/accounts/views.py (ch17l023 )
922
921
====
923
922
[source,python]
924
923
----
@@ -1416,7 +1415,7 @@ duplication in our tests. Let's see how it looks:
1416
1415
[source,python]
1417
1416
----
1418
1417
@mock.patch("accounts.views.auth") # <1>
1419
- def test_calls_authenticate_with_uid_from_get_request(self, mock_auth): # <1 >
1418
+ def test_calls_authenticate_with_uid_from_get_request(self, mock_auth): # <2 >
1420
1419
self.client.get("/accounts/login?token=abcd123")
1421
1420
self.assertEqual(
1422
1421
mock_auth.authenticate.call_args, # <3>
0 commit comments