apps.lyric.views updated with simpler FBV & test functionality for user login & authentication (some mocking employed); FT in test_simple_list_creation updated for new base.html content from several commits previous, now only FT not passing (to be expected) is under test_login
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from django.contrib import auth
|
||||
from django.test import TestCase
|
||||
from unittest import mock
|
||||
from ..models import Token, User
|
||||
from ..models import Token
|
||||
|
||||
class SendLoginEmailViewTest(TestCase):
|
||||
def test_redirects_to_home_page(self):
|
||||
@@ -78,6 +78,14 @@ class LoginViewTest(TestCase):
|
||||
message = list(response.context["messages"])[0]
|
||||
self.assertEqual(
|
||||
message.message,
|
||||
"Invalid login link!—please request a new one",
|
||||
"Invalid login link!—please request another",
|
||||
)
|
||||
self.assertEqual(message.tags, "error")
|
||||
|
||||
@mock.patch("apps.lyric.views.auth")
|
||||
def test_calls_authenticate_with_uid_from_get_request(self, mock_auth):
|
||||
self.client.get("/apps/lyric/login?token=abc123")
|
||||
self.assertEqual(
|
||||
mock_auth.authenticate.call_args,
|
||||
mock.call(uid="abc123")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user