updated apps.lyric.views for simpler login authentication and error messaging; .tests.test_views have new test method to assert either authentication condition has properly occurred
This commit is contained in:
@@ -70,3 +70,14 @@ class LoginViewTest(TestCase):
|
||||
user = auth.get_user(self.client)
|
||||
self.assertEqual(user.is_authenticated, True)
|
||||
self.assertEqual(user.email, "discoman@example.com")
|
||||
|
||||
def test_shows_login_error_if_token_invalid(self):
|
||||
response = self.client.get("/apps/lyric/login?token=invalid-token", follow=True)
|
||||
user = auth.get_user(self.client)
|
||||
self.assertEqual(user.is_authenticated, False)
|
||||
message = list(response.context["messages"])[0]
|
||||
self.assertEqual(
|
||||
message.message,
|
||||
"Invalid login link!—please request a new one",
|
||||
)
|
||||
self.assertEqual(message.tags, "error")
|
||||
|
||||
Reference in New Issue
Block a user