mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 17:47:08 +03:00
Merge pull request #3041 from arnav13081994/update_test_case
This commit is contained in:
commit
e5bc9af44c
|
@ -1,10 +1,11 @@
|
|||
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 +91,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