[Answered ]-Python django – how to unittest endpoints

2👍

reverse is for reversing to URL from views or url name AFAIK.

you can do either reverse('django.contrib.auth.views.login') or name the url and use the name

url(r'^accounts/login/$', 'django.contrib.auth.views.login', {
'template_name': 'login.html'
}, name="login"),
and reverse('login')

The test client in django also has login method to simulate user login.

See:

https://docs.djangoproject.com/en/1.7/topics/http/urls/#reverse-resolution-of-urls

https://docs.djangoproject.com/en/1.7/topics/testing/tools/#django.test.Client

Leave a comment