add GET request test to accounts/tests/test_disable_totp_view.py

This commit is contained in:
Trent Palmer 2021-04-20 19:02:38 -07:00
parent b006c72234
commit f1109519db

View File

@ -19,20 +19,27 @@ class TestDisableTOTPViewTestCase(TestCase):
user=user_b, user=user_b,
use_totp=True, totp_key=pyotp.random_base32()) use_totp=True, totp_key=pyotp.random_base32())
def test_dsable_totp_view_no_login(self): def test_disable_totp_view_get(self):
self.client.login(username='user_b', password='password_user_b')
response = self.client.get(reverse('accounts:disable_totp'))
self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'confirmation.html')
self.assertEquals(response.request['PATH_INFO'], '/accounts/disable-totp/')
def test_disable_totp_view_no_login(self):
response = self.client.post(reverse('accounts:disable_totp'), follow=True) response = self.client.post(reverse('accounts:disable_totp'), follow=True)
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'audio/index.html') self.assertTemplateUsed(response, 'audio/index.html')
self.assertEquals(response.request['PATH_INFO'], '/') self.assertEquals(response.request['PATH_INFO'], '/')
def test_dsable_totp_view_not_enabled(self): def test_disable_totp_view_not_enabled(self):
self.client.login(username='user_a', password='password_user_a') self.client.login(username='user_a', password='password_user_a')
response = self.client.post(reverse('accounts:disable_totp'), follow=True) response = self.client.post(reverse('accounts:disable_totp'), follow=True)
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'audio/index.html') self.assertTemplateUsed(response, 'audio/index.html')
self.assertEquals(response.request['PATH_INFO'], '/') self.assertEquals(response.request['PATH_INFO'], '/')
def test_dsable_totp_view(self): def test_disable_totp_view(self):
self.client.login(username='user_b', password='password_user_b') self.client.login(username='user_b', password='password_user_b')
response = self.client.post(reverse('accounts:disable_totp'), follow=True) response = self.client.post(reverse('accounts:disable_totp'), follow=True)
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)