fixes mocks on tests
This commit is contained in:
parent
ad7a045582
commit
bf6aca5122
5 changed files with 51 additions and 40 deletions
|
@ -65,8 +65,9 @@ class ReadingViews(TestCase):
|
|||
def test_start_reading_reshelf(self):
|
||||
''' begin a book '''
|
||||
to_read_shelf = self.local_user.shelf_set.get(identifier='to-read')
|
||||
models.ShelfBook.objects.create(
|
||||
shelf=to_read_shelf, book=self.book, user=self.local_user)
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
models.ShelfBook.objects.create(
|
||||
shelf=to_read_shelf, book=self.book, user=self.local_user)
|
||||
shelf = self.local_user.shelf_set.get(identifier='reading')
|
||||
self.assertEqual(to_read_shelf.books.get(), self.book)
|
||||
self.assertFalse(shelf.books.exists())
|
||||
|
|
|
@ -57,8 +57,9 @@ class StatusViews(TestCase):
|
|||
view = views.CreateStatus.as_view()
|
||||
user = models.User.objects.create_user(
|
||||
'rat', 'rat@rat.com', 'password', local=True)
|
||||
parent = models.Status.objects.create(
|
||||
content='parent status', user=self.local_user)
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
parent = models.Status.objects.create(
|
||||
content='parent status', user=self.local_user)
|
||||
form = forms.ReplyForm({
|
||||
'content': 'hi',
|
||||
'user': user.id,
|
||||
|
@ -219,8 +220,9 @@ class StatusViews(TestCase):
|
|||
def test_handle_delete_status(self):
|
||||
''' marks a status as deleted '''
|
||||
view = views.DeleteStatus.as_view()
|
||||
status = models.Status.objects.create(
|
||||
user=self.local_user, content='hi')
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
status = models.Status.objects.create(
|
||||
user=self.local_user, content='hi')
|
||||
self.assertFalse(status.deleted)
|
||||
request = self.factory.post('')
|
||||
request.user = self.local_user
|
||||
|
|
|
@ -39,9 +39,10 @@ class TagViews(TestCase):
|
|||
def test_tag_page(self):
|
||||
''' there are so many views, this just makes sure it LOADS '''
|
||||
view = views.Tag.as_view()
|
||||
tag = models.Tag.objects.create(name='hi there')
|
||||
models.UserTag.objects.create(
|
||||
tag=tag, user=self.local_user, book=self.book)
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
tag = models.Tag.objects.create(name='hi there')
|
||||
models.UserTag.objects.create(
|
||||
tag=tag, user=self.local_user, book=self.book)
|
||||
request = self.factory.get('')
|
||||
with patch('bookwyrm.views.tag.is_api_request') as is_api:
|
||||
is_api.return_value = False
|
||||
|
@ -82,9 +83,10 @@ class TagViews(TestCase):
|
|||
def test_untag(self):
|
||||
''' remove a tag from a book '''
|
||||
view = views.RemoveTag.as_view()
|
||||
tag = models.Tag.objects.create(name='A Tag!?')
|
||||
models.UserTag.objects.create(
|
||||
user=self.local_user, book=self.book, tag=tag)
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
tag = models.Tag.objects.create(name='A Tag!?')
|
||||
models.UserTag.objects.create(
|
||||
user=self.local_user, book=self.book, tag=tag)
|
||||
request = self.factory.post(
|
||||
'', {
|
||||
'user': self.local_user.id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue