mirror of https://github.com/snachodog/mybuddy.git
Add tests for user management tasks.
This commit is contained in:
parent
e234c1cfd2
commit
9796452da7
|
@ -55,6 +55,33 @@ class FormsTestCase(TestCase):
|
||||||
page = self.c.post('/user/password/', params)
|
page = self.c.post('/user/password/', params)
|
||||||
self.assertEqual(page.status_code, 200)
|
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):
|
def test_user_settings(self):
|
||||||
self.c.login(**self.credentials)
|
self.c.login(**self.credentials)
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,18 @@ class ViewsTestCase(TestCase):
|
||||||
page = self.c.get('/user/settings/')
|
page = self.c.get('/user/settings/')
|
||||||
self.assertEqual(page.status_code, 200)
|
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):
|
def test_welcome(self):
|
||||||
page = self.c.get('/welcome/')
|
page = self.c.get('/welcome/')
|
||||||
self.assertEqual(page.status_code, 200)
|
self.assertEqual(page.status_code, 200)
|
||||||
|
|
Loading…
Reference in New Issue