Mocks broadcast task for outgoing shelve tests

This commit is contained in:
Mouse Reeve 2020-11-27 14:18:45 -08:00
parent 4ec557fc5d
commit 9e48328e9e

View file

@ -1,3 +1,4 @@
from unittest.mock import patch
from django.test import TestCase from django.test import TestCase
from bookwyrm import models, outgoing from bookwyrm import models, outgoing
@ -25,39 +26,44 @@ class Shelving(TestCase):
) )
# def test_handle_shelve(self): def test_handle_shelve(self):
# outgoing.handle_shelve(self.user, self.book, self.shelf) with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
# # make sure the book is on the shelf outgoing.handle_shelve(self.user, self.book, self.shelf)
# self.assertEqual(self.shelf.books.get(), self.book) # make sure the book is on the shelf
# self.assertEqual(self.shelf.books.get(), self.book)
#
# def test_handle_shelve_to_read(self):
# shelf = models.Shelf.objects.get(identifier='to-read') def test_handle_shelve_to_read(self):
# shelf = models.Shelf.objects.get(identifier='to-read')
# outgoing.handle_shelve(self.user, self.book, shelf)
# # make sure the book is on the shelf with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
# self.assertEqual(shelf.books.get(), self.book) outgoing.handle_shelve(self.user, self.book, shelf)
# # make sure the book is on the shelf
# self.assertEqual(shelf.books.get(), self.book)
# def test_handle_shelve_reading(self):
# shelf = models.Shelf.objects.get(identifier='reading')
# def test_handle_shelve_reading(self):
# outgoing.handle_shelve(self.user, self.book, shelf) shelf = models.Shelf.objects.get(identifier='reading')
# # make sure the book is on the shelf
# self.assertEqual(shelf.books.get(), self.book) with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
# outgoing.handle_shelve(self.user, self.book, shelf)
# # make sure the book is on the shelf
# def test_handle_shelve_read(self): self.assertEqual(shelf.books.get(), self.book)
# shelf = models.Shelf.objects.get(identifier='read')
#
# outgoing.handle_shelve(self.user, self.book, shelf) def test_handle_shelve_read(self):
# # make sure the book is on the shelf shelf = models.Shelf.objects.get(identifier='read')
# self.assertEqual(shelf.books.get(), self.book)
# with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
# outgoing.handle_shelve(self.user, self.book, shelf)
# def test_handle_unshelve(self): # make sure the book is on the shelf
# self.shelf.books.add(self.book) self.assertEqual(shelf.books.get(), self.book)
# self.shelf.save()
# self.assertEqual(self.shelf.books.count(), 1)
# outgoing.handle_unshelve(self.user, self.book, self.shelf) def test_handle_unshelve(self):
# self.assertEqual(self.shelf.books.count(), 0) self.shelf.books.add(self.book)
self.shelf.save()
self.assertEqual(self.shelf.books.count(), 1)
with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
outgoing.handle_unshelve(self.user, self.book, self.shelf)
self.assertEqual(self.shelf.books.count(), 0)