def test_profile_url_with_auth_user(self): request = self.factory.get(settings.LOGIN_REDIRECT_URL) request.user = self.user response = AccountEditView.as_view()(request) self.assertEqual(response.status_code, 200) self.assertContains(response, 'value="{}"'.format(self.username)) self.assertContains(response, 'value="{}"'.format(self.email))
def test_profile_url_without_auth_user(self): request = self.factory.get(settings.LOGIN_REDIRECT_URL) request.user = AnonymousUser() response = AccountEditView.as_view()(request) self.assertEqual(response.status_code, 302)
from django.conf.urls import patterns, url from webaccount.views import AccountAuthView, AccountEditView, logout_view urlpatterns = patterns( '', url(r'^login/$', AccountAuthView.as_view(), name='login_registration'), url(r'^logout/$', logout_view, name='logout'), url(r'^profile/$', AccountEditView.as_view(), name='profile'), )