From d8be9a62b5dc0f65a02c09e580f4dcc26d857ee1 Mon Sep 17 00:00:00 2001 From: Sli Date: Fri, 11 Apr 2025 17:31:03 +0200 Subject: [PATCH] Use assertRedirects for test_not_authorized --- eboutic/tests/test_billing_info.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eboutic/tests/test_billing_info.py b/eboutic/tests/test_billing_info.py index 42db98ce..42331b6e 100644 --- a/eboutic/tests/test_billing_info.py +++ b/eboutic/tests/test_billing_info.py @@ -4,6 +4,7 @@ import pytest from django.test import Client from django.urls import reverse from model_bakery import baker +from pytest_django.asserts import assertRedirects from core.baker_recipes import subscriber_user from core.models import User @@ -29,8 +30,10 @@ class TestBillingInfo: reverse("eboutic:billing_infos"), payload, ) - assert response.status_code == 302 - assert response["Location"].startswith(reverse("core:login")) + assertRedirects( + response, + reverse("core:login", query={"next": reverse("eboutic:billing_infos")}), + ) def test_edit_infos(self, client: Client, payload: dict[str, str]): user = subscriber_user.make()