mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 03:51:08 +00:00
Adds view tests
This commit is contained in:
parent
c630ec3572
commit
c4f2d67048
1 changed files with 32 additions and 0 deletions
|
@ -3,6 +3,7 @@ import json
|
|||
from unittest.mock import patch
|
||||
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
|
@ -66,6 +67,37 @@ class ListActionViews(TestCase):
|
|||
self.anonymous_user.is_authenticated = False
|
||||
models.SiteSettings.objects.create()
|
||||
|
||||
def test_delete_list(self):
|
||||
"""delete an entire list"""
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
book=self.book,
|
||||
approved=True,
|
||||
order=1,
|
||||
)
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
book=self.book_two,
|
||||
approved=False,
|
||||
order=2,
|
||||
)
|
||||
request = self.factory.post("")
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
views.delete_list(request, self.list.id)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
self.assertFalse(models.List.objects.exists())
|
||||
self.assertFalse(models.ListItem.objects.exists())
|
||||
|
||||
def test_delete_list_permission_denied(self):
|
||||
"""delete an entire list"""
|
||||
request = self.factory.post("")
|
||||
request.user = self.rat
|
||||
with self.assertRaises(PermissionDenied):
|
||||
views.delete_list(request, self.list.id)
|
||||
|
||||
def test_curate_approve(self):
|
||||
"""approve a pending item"""
|
||||
view = views.Curate.as_view()
|
||||
|
|
Loading…
Reference in a new issue