mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-11 12:17:37 +03:00
Removed unnecessary test for username case sensitivity since django usernames are case sensitive by default. Also made the redirecting to the login url more dynamic by fetching the defined login_url from settings
This commit is contained in:
parent
fc01e870bd
commit
fc8e2ea8a2
|
@ -1,10 +1,12 @@
|
|||
import pytest
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.contrib.messages.middleware import MessageMiddleware
|
||||
from django.contrib.sessions.middleware import SessionMiddleware
|
||||
from django.http.response import Http404
|
||||
from django.test import RequestFactory
|
||||
from django.urls import reverse
|
||||
|
||||
from {{ cookiecutter.project_slug }}.users.forms import UserChangeForm
|
||||
from {{ cookiecutter.project_slug }}.users.models import User
|
||||
|
@ -90,13 +92,7 @@ class TestUserDetailView:
|
|||
request.user = AnonymousUser()
|
||||
|
||||
response = user_detail_view(request, username=user.username)
|
||||
login_url = reverse(settings.LOGIN_URL)
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.url == "/accounts/login/?next=/fake-url/"
|
||||
|
||||
def test_case_sensitivity(self, rf: RequestFactory):
|
||||
request = rf.get("/fake-url/")
|
||||
request.user = UserFactory(username="UserName")
|
||||
|
||||
with pytest.raises(Http404):
|
||||
user_detail_view(request, username="username")
|
||||
assert response.url == f"{login_url}?next=/fake-url/"
|
||||
|
|
Loading…
Reference in New Issue
Block a user