def test_logout_while_logged_in(self): self.client.force_login(self.user) response = self.client.get(reverse('logout')) self.assertEqual(response.status_code, 200) self.assertEqual(response.resolver_match.func.__name__, LogoutView.as_view().__name__) self.assertTemplateUsed(response, 'registration/login.html') tempURL = createTempViewURL() response = self.client.get(tempURL) self.assertEqual(response['location'], "/login/?next=" + tempURL)
def test_logout_while_logged_out(self): response = self.client.get(reverse('logout')) self.assertEqual(response.status_code, 200) self.assertEqual(response.resolver_match.func.__name__, LogoutView.as_view().__name__) self.assertTemplateUsed(response, 'registration/login.html')
from django.contrib import admin from django.urls import path, include from user_management.views import LoginView, LogoutView urlpatterns = [ path('login/', LoginView.as_view(), name='login'), path('logout/', LogoutView.as_view(), name='logout'), path('', admin.site.urls), path('api/v1/', include('api.urls')) ]