mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 03:51:08 +00:00
Adds remove member tests
This commit is contained in:
parent
d546d9dce9
commit
3aebb54feb
1 changed files with 41 additions and 0 deletions
|
@ -188,3 +188,44 @@ class GroupViews(TestCase):
|
|||
result = views.remove_member(request)
|
||||
# nothing happens
|
||||
self.assertEqual(result.status_code, 302)
|
||||
|
||||
def test_remove_member_invited(self, _):
|
||||
"""remove an invited member"""
|
||||
models.GroupMemberInvitation.objects.create(
|
||||
user=self.rat,
|
||||
group=self.testgroup,
|
||||
)
|
||||
request = self.factory.post(
|
||||
"",
|
||||
{
|
||||
"group": self.testgroup.id,
|
||||
"user": self.rat.localname,
|
||||
},
|
||||
)
|
||||
request.user = self.local_user
|
||||
result = views.remove_member(request)
|
||||
self.assertEqual(result.status_code, 302)
|
||||
self.assertFalse(models.GroupMemberInvitation.objects.exists())
|
||||
|
||||
def test_remove_member_existing_member(self, _):
|
||||
"""remove an invited member"""
|
||||
models.GroupMember.objects.create(
|
||||
user=self.rat,
|
||||
group=self.testgroup,
|
||||
)
|
||||
request = self.factory.post(
|
||||
"",
|
||||
{
|
||||
"group": self.testgroup.id,
|
||||
"user": self.rat.localname,
|
||||
},
|
||||
)
|
||||
request.user = self.local_user
|
||||
result = views.remove_member(request)
|
||||
self.assertEqual(result.status_code, 302)
|
||||
self.assertEqual(models.GroupMember.objects.count(), 1)
|
||||
self.assertEqual(models.GroupMember.objects.first().user, self.local_user)
|
||||
notification = models.Notification.objects.get()
|
||||
self.assertEqual(notification.user, self.rat)
|
||||
self.assertEqual(notification.related_group, self.testgroup)
|
||||
self.assertEqual(notification.notification_type, "REMOVE")
|
||||
|
|
Loading…
Reference in a new issue