2021-04-07 15:41:22 -07:00
|
|
|
from django.test import SimpleTestCase
|
|
|
|
from django.urls import reverse, resolve
|
|
|
|
from accounts.views import log_out, password_change, register, edit_profile
|
|
|
|
from accounts.login import log_in, two_factor_input
|
|
|
|
from accounts.enable_totp import enable_totp, disable_totp
|
2021-04-09 02:29:08 -07:00
|
|
|
from accounts.urls import urlpatterns
|
|
|
|
|
|
|
|
|
|
|
|
class TestNumUrls(SimpleTestCase):
|
|
|
|
|
|
|
|
def test_num_urls(self):
|
|
|
|
self.assertEquals(len(urlpatterns), 12)
|
2021-04-07 15:41:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
class TestViewsUrls(SimpleTestCase):
|
|
|
|
|
|
|
|
def test_password_change_url_is_resolved(self):
|
|
|
|
url = reverse('accounts:password_change')
|
|
|
|
self.assertEquals(resolve(url).func, password_change)
|
|
|
|
|
|
|
|
def test_register_url_is_resolved(self):
|
|
|
|
url = reverse('accounts:register')
|
|
|
|
self.assertEquals(resolve(url).func, register)
|
|
|
|
|
|
|
|
def test_logout_url_is_resolved(self):
|
|
|
|
url = reverse('accounts:logout')
|
|
|
|
self.assertEquals(resolve(url).func, log_out)
|
|
|
|
|
|
|
|
def test_edit_profile_url_is_resolved(self):
|
|
|
|
url = reverse('accounts:edit_profile')
|
|
|
|
self.assertEquals(resolve(url).func, edit_profile)
|
|
|
|
|
|
|
|
|
|
|
|
class TestLoginViewsUrls(SimpleTestCase):
|
|
|
|
|
|
|
|
def test_login_url_is_resolved(self):
|
|
|
|
url = reverse('accounts:login')
|
|
|
|
self.assertEquals(resolve(url).func, log_in)
|
|
|
|
|
|
|
|
def test_2fa_url_is_resolved(self):
|
|
|
|
url = reverse('accounts:two_factor_input')
|
|
|
|
self.assertEquals(resolve(url).func, two_factor_input)
|
|
|
|
|
|
|
|
|
|
|
|
class TestEnableTotpUrls(SimpleTestCase):
|
|
|
|
|
|
|
|
def test_enable_totp_url_is_resolved(self):
|
|
|
|
url = reverse('accounts:enable_totp')
|
|
|
|
self.assertEquals(resolve(url).func, enable_totp)
|
|
|
|
|
|
|
|
def test_disable_totp_url_is_resolved(self):
|
|
|
|
url = reverse('accounts:disable_totp')
|
|
|
|
self.assertEquals(resolve(url).func, disable_totp)
|