mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-14 21:01:06 +00:00
Test leaving a group (as opposed to being removed)
This test will catch my typo in generating the notifications
This commit is contained in:
parent
b61a4ab994
commit
2cda9d5567
1 changed files with 24 additions and 0 deletions
|
@ -257,6 +257,30 @@ class GroupViews(TestCase):
|
|||
self.assertEqual(notification.related_group, self.testgroup)
|
||||
self.assertEqual(notification.notification_type, "REMOVE")
|
||||
|
||||
def test_remove_member_remove_self(self, _):
|
||||
"""Leave a group"""
|
||||
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.rat
|
||||
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.local_user)
|
||||
self.assertEqual(notification.related_group, self.testgroup)
|
||||
self.assertEqual(notification.notification_type, "LEAVE")
|
||||
|
||||
|
||||
def test_accept_membership(self, _):
|
||||
"""accept an invite"""
|
||||
models.GroupMemberInvitation.objects.create(
|
||||
|
|
Loading…
Reference in a new issue