def test_shelve_read_with_change_shelf(self, *_): """special behavior for the read shelf""" previous_shelf = models.Shelf.objects.get(identifier="reading") models.ShelfBook.objects.create(shelf=previous_shelf, user=self.local_user, book=self.book) shelf = models.Shelf.objects.get(identifier="read") request = self.factory.post( "", { "book": self.book.id, "shelf": shelf.identifier, "change-shelf-from": previous_shelf.identifier, }, ) request.user = self.local_user with patch( "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" ): views.shelve(request) # make sure the book is on the shelf self.assertEqual(shelf.books.get(), self.book) self.assertEqual(list(previous_shelf.books.all()), [])
def test_handle_shelve(self, _): """ shelve a book """ request = self.factory.post("", { "book": self.book.id, "shelf": self.shelf.identifier }) request.user = self.local_user with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): views.shelve(request) # make sure the book is on the shelf self.assertEqual(self.shelf.books.get(), self.book)
def test_handle_shelve(self, _): ''' shelve a book ''' request = self.factory.post('', { 'book': self.book.id, 'shelf': self.shelf.identifier }) request.user = self.local_user with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'): views.shelve(request) # make sure the book is on the shelf self.assertEqual(self.shelf.books.get(), self.book)
def test_handle_shelve_read(self, _): """special behavior for the read shelf""" shelf = models.Shelf.objects.get(identifier="read") request = self.factory.post("", { "book": self.book.id, "shelf": shelf.identifier }) request.user = self.local_user with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): views.shelve(request) # make sure the book is on the shelf self.assertEqual(shelf.books.get(), self.book)
def test_handle_shelve_read(self, _): ''' special behavior for the read shelf ''' shelf = models.Shelf.objects.get(identifier='read') request = self.factory.post('', { 'book': self.book.id, 'shelf': shelf.identifier }) request.user = self.local_user with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'): views.shelve(request) # make sure the book is on the shelf self.assertEqual(shelf.books.get(), self.book)
def test_handle_shelve(self, _): """shelve a book""" request = self.factory.post("", { "book": self.book.id, "shelf": self.shelf.identifier }) request.user = self.local_user with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay" ) as mock: views.shelve(request) self.assertEqual(mock.call_count, 1) activity = json.loads(mock.call_args[0][1]) self.assertEqual(activity["type"], "Add") item = models.ShelfBook.objects.get() self.assertEqual(activity["object"]["id"], item.remote_id) # make sure the book is on the shelf self.assertEqual(self.shelf.books.get(), self.book)