Adds saved list view test
This commit is contained in:
parent
f7c8a550cf
commit
b890e93533
|
@ -49,8 +49,6 @@ class Activitystreams(TestCase):
|
||||||
|
|
||||||
def test_populate_streams(self, *_):
|
def test_populate_streams(self, *_):
|
||||||
"""make sure the function on the redis manager gets called"""
|
"""make sure the function on the redis manager gets called"""
|
||||||
with patch(
|
with patch("bookwyrm.lists_stream.populate_lists_task.delay") as list_mock:
|
||||||
"bookwyrm.lists_stream.populate_lists_task.delay"
|
|
||||||
) as list_mock:
|
|
||||||
populate_lists_streams()
|
populate_lists_streams()
|
||||||
self.assertEqual(list_mock.call_count, 2) # 2 users
|
self.assertEqual(list_mock.call_count, 2) # 2 users
|
||||||
|
|
|
@ -551,12 +551,7 @@ class ListActionViews(TestCase):
|
||||||
)
|
)
|
||||||
self.assertTrue(self.list.listitem_set.exists())
|
self.assertTrue(self.list.listitem_set.exists())
|
||||||
|
|
||||||
request = self.factory.post(
|
request = self.factory.post("", {"item": item.id})
|
||||||
"",
|
|
||||||
{
|
|
||||||
"item": item.id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||||
|
@ -570,14 +565,22 @@ class ListActionViews(TestCase):
|
||||||
book_list=self.list, user=self.local_user, book=self.book, order=1
|
book_list=self.list, user=self.local_user, book=self.book, order=1
|
||||||
)
|
)
|
||||||
self.assertTrue(self.list.listitem_set.exists())
|
self.assertTrue(self.list.listitem_set.exists())
|
||||||
request = self.factory.post(
|
request = self.factory.post("", {"item": item.id})
|
||||||
"",
|
|
||||||
{
|
|
||||||
"item": item.id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
request.user = self.rat
|
request.user = self.rat
|
||||||
|
|
||||||
with self.assertRaises(PermissionDenied):
|
with self.assertRaises(PermissionDenied):
|
||||||
views.list.remove_book(request, self.list.id)
|
views.list.remove_book(request, self.list.id)
|
||||||
self.assertTrue(self.list.listitem_set.exists())
|
self.assertTrue(self.list.listitem_set.exists())
|
||||||
|
|
||||||
|
def test_save_unsave_list(self):
|
||||||
|
"""bookmark a list"""
|
||||||
|
self.assertFalse(self.local_user.saved_lists.exists())
|
||||||
|
request = self.factory.post("")
|
||||||
|
request.user = self.local_user
|
||||||
|
views.save_list(request, self.list.id)
|
||||||
|
self.local_user.refresh_from_db()
|
||||||
|
self.assertEqual(self.local_user.saved_lists.first(), self.list)
|
||||||
|
|
||||||
|
views.unsave_list(request, self.list.id)
|
||||||
|
self.local_user.refresh_from_db()
|
||||||
|
self.assertFalse(self.local_user.saved_lists.exists())
|
||||||
|
|
Loading…
Reference in New Issue