Commit ea6124b3 by Bach Dániel

dashboard: update tests

parent fcf7744c
...@@ -1479,6 +1479,8 @@ class GroupDetailTest(LoginMixin, TestCase): ...@@ -1479,6 +1479,8 @@ class GroupDetailTest(LoginMixin, TestCase):
user_count = self.g1.user_set.count() user_count = self.g1.user_set.count()
c = Client() c = Client()
self.login(c, 'user1') self.login(c, 'user1')
self.u1.user_permissions.add(Permission.objects.get(
name='Can add user'))
response = c.post('/dashboard/group/%d/create/' % self.g1.pk, response = c.post('/dashboard/group/%d/create/' % self.g1.pk,
{'username': 'userx1', {'username': 'userx1',
'password1': 'test123', 'password1': 'test123',
...@@ -1494,7 +1496,10 @@ class GroupDetailTest(LoginMixin, TestCase): ...@@ -1494,7 +1496,10 @@ class GroupDetailTest(LoginMixin, TestCase):
{'username': 'userx2', {'username': 'userx2',
'password1': 'test123', 'password1': 'test123',
'password2': 'test123'}) 'password2': 'test123'})
self.assertEqual(response.status_code, 403) self.assertRedirects(
response,
'/accounts/login/?next=/dashboard/group/%d/create/' % self.g1.pk)
self.assertEqual(response.status_code, 302)
self.assertEqual(user_count, self.g1.user_set.count()) self.assertEqual(user_count, self.g1.user_set.count())
def test_permitted_user_add(self): def test_permitted_user_add(self):
...@@ -1507,6 +1512,7 @@ class GroupDetailTest(LoginMixin, TestCase): ...@@ -1507,6 +1512,7 @@ class GroupDetailTest(LoginMixin, TestCase):
{'username': 'userx2', {'username': 'userx2',
'password1': 'test123', 'password1': 'test123',
'password2': 'test123'}) 'password2': 'test123'})
self.assertRedirects(response, '/dashboard/group/%d/' % self.g1.pk)
self.assertEqual(user_count + 1, self.g1.user_set.count()) self.assertEqual(user_count + 1, self.g1.user_set.count())
self.assertEqual(response.status_code, 302) self.assertEqual(response.status_code, 302)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment