refactored to green: all references in urlpatterns thruout project to apps/ dir now skip it & point directly to the app contained w.in (i.e., not apps/lyric/ or apps/dashboard/, but lyric/ or dashboard/ now
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Disco DeDisco
2026-02-22 22:08:34 -05:00
parent a8c199b719
commit 94f3120add
5 changed files with 39 additions and 39 deletions

View File

@@ -9,13 +9,13 @@ from apps.lyric.models import Token
class SendLoginEmailViewTest(TestCase):
def test_redirects_to_home_page(self, mock_delay):
response = self.client.post(
"/apps/lyric/send_login_email", data={"email": "discoman@example.com"}
"/lyric/send_login_email", data={"email": "discoman@example.com"}
)
self.assertRedirects(response, "/")
def test_sends_mail_to_address_from_post(self, mock_delay):
self.client.post(
"/apps/lyric/send_login_email", data={"email": "discoman@example.com"}
"/lyric/send_login_email", data={"email": "discoman@example.com"}
)
self.assertEqual(mock_delay.called, True)
@@ -23,7 +23,7 @@ class SendLoginEmailViewTest(TestCase):
def test_adds_success_message(self, mock_delay):
response = self.client.post(
"/apps/lyric/send_login_email",
"/lyric/send_login_email",
data={"email": "discoman@example.com"},
follow=True
)
@@ -37,23 +37,23 @@ class SendLoginEmailViewTest(TestCase):
def test_creates_token_associated_with_email(self, mock_delay):
self.client.post(
"/apps/lyric/send_login_email", data={"email": "discoman@example.com"}
"/lyric/send_login_email", data={"email": "discoman@example.com"}
)
token = Token.objects.get()
self.assertEqual(token.email, "discoman@example.com")
def test_sends_link_to_login_using_token_uid(self, mock_delay):
self.client.post(
"/apps/lyric/send_login_email", data={"email": "discoman@example.com"}
"/lyric/send_login_email", data={"email": "discoman@example.com"}
)
token = Token.objects.get()
expected_url = f"http://testserver/apps/lyric/login?token={token.uid}"
expected_url = f"http://testserver/lyric/login?token={token.uid}"
self.assertEqual(mock_delay.call_args.args[1], expected_url)
class LoginViewTest(TestCase):
def test_redirects_to_home_page(self):
response = self.client.get("/apps/lyric/login?token=abc123")
response = self.client.get("/lyric/login?token=abc123")
self.assertRedirects(response, "/")
def test_logs_in_if_given_valid_token(self):
@@ -61,14 +61,14 @@ class LoginViewTest(TestCase):
self.assertEqual(anon_user.is_authenticated, False)
token = Token.objects.create(email="discoman@example.com")
self.client.get(f"/apps/lyric/login?token={token.uid}", follow=True)
self.client.get(f"/lyric/login?token={token.uid}", follow=True)
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)
response = self.client.get("/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]
@@ -80,7 +80,7 @@ class LoginViewTest(TestCase):
@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.client.get("/lyric/login?token=abc123")
self.assertEqual(
mock_auth.authenticate.call_args,
mock.call(uid="abc123")