Add tests for user management tasks.

This commit is contained in:
Christopher Charbonneau Wells 2017-12-11 17:18:22 -05:00
parent e234c1cfd2
commit 9796452da7
2 changed files with 39 additions and 0 deletions

View File

@ -55,6 +55,33 @@ class FormsTestCase(TestCase):
page = self.c.post('/user/password/', params)
self.assertEqual(page.status_code, 200)
def test_user_forms(self):
self.c.login(**self.credentials)
params = {
'username': 'username',
'first_name': 'User',
'last_name': 'Name',
'email': 'user@user.user',
'password1': 'password',
'password2': 'password'
}
page = self.c.post('/user/add/', params)
self.assertEqual(page.status_code, 302)
new_user = User.objects.get(username='username')
self.assertIsInstance(new_user, User)
params['first_name'] = 'Changed'
page = self.c.post('/user/{}/'.format(new_user.id), params)
self.assertEqual(page.status_code, 302)
new_user.refresh_from_db()
self.assertEqual(new_user.first_name, params['first_name'])
page = self.c.post('/user/{}/delete/'.format(new_user.id))
self.assertEqual(page.status_code, 302)
self.assertQuerysetEqual(User.objects.filter(username='username'), [])
def test_user_settings(self):
self.c.login(**self.credentials)

View File

@ -61,6 +61,18 @@ class ViewsTestCase(TestCase):
page = self.c.get('/user/settings/')
self.assertEqual(page.status_code, 200)
def test_user_views(self):
page = self.c.get('/user/list/')
self.assertEqual(page.status_code, 200)
page = self.c.get('/user/add/')
self.assertEqual(page.status_code, 200)
entry = User.objects.first()
page = self.c.get('/user/{}/'.format(entry.id))
self.assertEqual(page.status_code, 200)
page = self.c.get('/user/{}/delete/'.format(entry.id))
self.assertEqual(page.status_code, 200)
def test_welcome(self):
page = self.c.get('/welcome/')
self.assertEqual(page.status_code, 200)