mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Update shelf test now that it has multiple users
This commit is contained in:
parent
3f47cca5e6
commit
317a239d40
1 changed files with 9 additions and 17 deletions
|
@ -74,7 +74,7 @@ class ShelfActionViews(TestCase):
|
|||
|
||||
def test_shelve_to_read(self, *_):
|
||||
"""special behavior for the to-read shelf"""
|
||||
shelf = models.Shelf.objects.get(identifier="to-read")
|
||||
shelf = models.Shelf.objects.get(user=self.local_user, identifier="to-read")
|
||||
request = self.factory.post(
|
||||
"", {"book": self.book.id, "shelf": shelf.identifier}
|
||||
)
|
||||
|
@ -87,7 +87,7 @@ class ShelfActionViews(TestCase):
|
|||
|
||||
def test_shelve_reading(self, *_):
|
||||
"""special behavior for the reading shelf"""
|
||||
shelf = models.Shelf.objects.get(identifier="reading")
|
||||
shelf = models.Shelf.objects.get(user=self.local_user, identifier="reading")
|
||||
request = self.factory.post(
|
||||
"", {"book": self.book.id, "shelf": shelf.identifier}
|
||||
)
|
||||
|
@ -100,7 +100,7 @@ class ShelfActionViews(TestCase):
|
|||
|
||||
def test_shelve_read(self, *_):
|
||||
"""special behavior for the read shelf"""
|
||||
shelf = models.Shelf.objects.get(identifier="read")
|
||||
shelf = models.Shelf.objects.get(user=self.local_user, identifier="read")
|
||||
request = self.factory.post(
|
||||
"", {"book": self.book.id, "shelf": shelf.identifier}
|
||||
)
|
||||
|
@ -113,11 +113,13 @@ class ShelfActionViews(TestCase):
|
|||
|
||||
def test_shelve_read_with_change_shelf(self, *_):
|
||||
"""special behavior for the read shelf"""
|
||||
previous_shelf = models.Shelf.objects.get(identifier="reading")
|
||||
previous_shelf = models.Shelf.objects.get(
|
||||
user=self.local_user, identifier="reading"
|
||||
)
|
||||
models.ShelfBook.objects.create(
|
||||
shelf=previous_shelf, user=self.local_user, book=self.book
|
||||
)
|
||||
shelf = models.Shelf.objects.get(identifier="read")
|
||||
shelf = models.Shelf.objects.get(user=self.local_user, identifier="read")
|
||||
|
||||
request = self.factory.post(
|
||||
"",
|
||||
|
@ -168,7 +170,7 @@ class ShelfActionViews(TestCase):
|
|||
|
||||
views.create_shelf(request)
|
||||
|
||||
shelf = models.Shelf.objects.get(name="new shelf name")
|
||||
shelf = models.Shelf.objects.get(user=self.local_user, name="new shelf name")
|
||||
self.assertEqual(shelf.privacy, "unlisted")
|
||||
self.assertEqual(shelf.description, "desc")
|
||||
self.assertEqual(shelf.user, self.local_user)
|
||||
|
@ -198,18 +200,8 @@ class ShelfActionViews(TestCase):
|
|||
|
||||
def test_delete_shelf_unauthorized(self, *_):
|
||||
"""delete a brand new custom shelf"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
rat = models.User.objects.create_user(
|
||||
"rat@local.com",
|
||||
"rat@mouse.mouse",
|
||||
"password",
|
||||
local=True,
|
||||
localname="rat",
|
||||
)
|
||||
request = self.factory.post("")
|
||||
request.user = rat
|
||||
request.user = self.another_user
|
||||
|
||||
with self.assertRaises(PermissionDenied):
|
||||
views.delete_shelf(request, self.shelf.id)
|
||||
|
|
Loading…
Reference in a new issue