forked from DGNum/gestioCOF
more robust tests
This commit is contained in:
parent
4ac7b30bdd
commit
e0b1db1e1e
2 changed files with 11 additions and 4 deletions
|
@ -28,7 +28,11 @@ class UserGroupFormTests(TestCase):
|
|||
"""Only K-Fêt groups are selectable."""
|
||||
form = UserGroupForm(instance=self.user)
|
||||
groups_field = form.fields['groups']
|
||||
self.assertEqual(len(groups_field.choices), len(self.kfet_groups))
|
||||
self.assertQuerysetEqual(
|
||||
groups_field.queryset,
|
||||
[repr(g) for g in self.kfet_groups],
|
||||
ordered=False,
|
||||
)
|
||||
|
||||
def test_keep_others(self):
|
||||
"""User stays in its non-K-Fêt groups."""
|
||||
|
@ -45,4 +49,8 @@ class UserGroupFormTests(TestCase):
|
|||
|
||||
form.is_valid()
|
||||
form.save()
|
||||
self.assertEqual(len(user.groups.all()), 1+len(self.kfet_groups))
|
||||
self.assertQuerysetEqual(
|
||||
user.groups.all(),
|
||||
[repr(g) for g in [self.other_group] + self.kfet_groups],
|
||||
ordered=False,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue