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:
Disco DeDisco
2026-01-30 21:51:06 -05:00
parent ae63861adb
commit 9c102ac0f5
2 changed files with 14 additions and 7 deletions

View File

@@ -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")