Adds delete test

This commit is contained in:
Mouse Reeve 2021-12-09 19:00:48 -08:00
parent 9c86bb1bc3
commit 234d44b5c7
2 changed files with 20 additions and 12 deletions

View file

@ -1,12 +1,11 @@
""" test for app action functionality """
from unittest.mock import patch
from django.contrib.auth import decorators
from django.template.response import TemplateResponse
from django.test import TestCase
from django.test.client import RequestFactory
from bookwyrm import models, views, forms
from bookwyrm import models, views
from bookwyrm.tests.validate_html import validate_html
@ -28,15 +27,15 @@ class GroupViews(TestCase):
localname="mouse",
)
self.testgroup = models.Group.objects.create(
name="Test Group",
description="Initial description",
user=self.local_user,
privacy="public",
)
self.membership = models.GroupMember.objects.create(
group=self.testgroup, user=self.local_user
)
self.testgroup = models.Group.objects.create(
name="Test Group",
description="Initial description",
user=self.local_user,
privacy="public",
)
self.membership = models.GroupMember.objects.create(
group=self.testgroup, user=self.local_user
)
models.SiteSettings.objects.create()
@ -117,3 +116,13 @@ class GroupViews(TestCase):
self.assertEqual(self.testgroup.name, "Updated Group name")
self.assertEqual(self.testgroup.description, "wow")
self.assertEqual(self.testgroup.privacy, "direct")
def test_delete_group(self, _):
"""delete a group"""
request = self.factory.post("")
request.user = self.local_user
views.delete_group(request, self.testgroup.id)
self.assertFalse(models.Group.objects.exists())
def test_invite_member(self, _):
"""invite a member to a group"""

View file

@ -179,7 +179,6 @@ def delete_group(request, group_id):
@login_required
def invite_member(request):
"""invite a member to the group"""
group = get_object_or_404(models.Group, id=request.POST.get("group"))
if not group:
return HttpResponseBadRequest()