forked from mirrors/bookwyrm
fixes mocks on tests
This commit is contained in:
parent
ad7a045582
commit
bf6aca5122
5 changed files with 51 additions and 40 deletions
|
@ -124,7 +124,7 @@ class GoodreadsImport(TestCase):
|
|||
job_id=import_job.id, index=index, data=entry, book=self.book)
|
||||
break
|
||||
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
goodreads_import.handle_imported_book(
|
||||
self.user, import_item, False, 'public')
|
||||
|
||||
|
@ -144,6 +144,7 @@ class GoodreadsImport(TestCase):
|
|||
|
||||
def test_handle_imported_book_already_shelved(self):
|
||||
''' goodreads import added a book, this adds related connections '''
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
shelf = self.user.shelf_set.filter(identifier='to-read').first()
|
||||
models.ShelfBook.objects.create(
|
||||
shelf=shelf, user=self.user, book=self.book)
|
||||
|
@ -156,7 +157,7 @@ class GoodreadsImport(TestCase):
|
|||
job_id=import_job.id, index=index, data=entry, book=self.book)
|
||||
break
|
||||
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
goodreads_import.handle_imported_book(
|
||||
self.user, import_item, False, 'public')
|
||||
|
||||
|
@ -185,7 +186,7 @@ class GoodreadsImport(TestCase):
|
|||
job_id=import_job.id, index=index, data=entry, book=self.book)
|
||||
break
|
||||
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
goodreads_import.handle_imported_book(
|
||||
self.user, import_item, False, 'public')
|
||||
goodreads_import.handle_imported_book(
|
||||
|
@ -214,7 +215,7 @@ class GoodreadsImport(TestCase):
|
|||
import_item = models.ImportItem.objects.create(
|
||||
job_id=import_job.id, index=0, data=entry, book=self.book)
|
||||
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
goodreads_import.handle_imported_book(
|
||||
self.user, import_item, True, 'unlisted')
|
||||
review = models.Review.objects.get(book=self.book, user=self.user)
|
||||
|
@ -235,7 +236,7 @@ class GoodreadsImport(TestCase):
|
|||
import_item = models.ImportItem.objects.create(
|
||||
job_id=import_job.id, index=0, data=entry, book=self.book)
|
||||
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
goodreads_import.handle_imported_book(
|
||||
self.user, import_item, False, 'unlisted')
|
||||
self.assertFalse(models.Review.objects.filter(
|
||||
|
|
|
@ -22,7 +22,7 @@ class Incoming(TestCase):
|
|||
'mouse@example.com', 'mouse@mouse.com', 'mouseword',
|
||||
local=True, localname='mouse')
|
||||
self.local_user.remote_id = 'https://example.com/user/mouse'
|
||||
self.local_user.save()
|
||||
self.local_user.save(broadcast=False)
|
||||
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||
self.remote_user = models.User.objects.create_user(
|
||||
'rat', 'rat@rat.com', 'ratword',
|
||||
|
@ -31,6 +31,7 @@ class Incoming(TestCase):
|
|||
inbox='https://example.com/users/rat/inbox',
|
||||
outbox='https://example.com/users/rat/outbox',
|
||||
)
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
self.status = models.Status.objects.create(
|
||||
user=self.local_user,
|
||||
content='Test status',
|
||||
|
@ -177,6 +178,7 @@ class Incoming(TestCase):
|
|||
"object": "https://example.com/user/mouse"
|
||||
}
|
||||
}
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
models.UserFollows.objects.create(
|
||||
user_subject=self.remote_user, user_object=self.local_user)
|
||||
self.assertEqual(self.remote_user, self.local_user.followers.first())
|
||||
|
@ -200,6 +202,7 @@ class Incoming(TestCase):
|
|||
}
|
||||
}
|
||||
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
models.UserFollowRequest.objects.create(
|
||||
user_subject=self.local_user,
|
||||
user_object=self.remote_user
|
||||
|
@ -232,6 +235,7 @@ class Incoming(TestCase):
|
|||
}
|
||||
}
|
||||
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
models.UserFollowRequest.objects.create(
|
||||
user_subject=self.local_user,
|
||||
user_object=self.remote_user
|
||||
|
@ -280,6 +284,7 @@ class Incoming(TestCase):
|
|||
|
||||
def test_handle_update_list(self):
|
||||
''' a new list '''
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
book_list = models.List.objects.create(
|
||||
name='hi', remote_id='https://example.com/list/22',
|
||||
user=self.local_user)
|
||||
|
@ -539,7 +544,7 @@ class Incoming(TestCase):
|
|||
activity = {
|
||||
"id": "https://bookwyrm.social/shelfbook/6189#add",
|
||||
"type": "Add",
|
||||
"actor": "hhttps://example.com/users/rat",
|
||||
"actor": "https://example.com/users/rat",
|
||||
"object": "https://bookwyrm.social/book/37292",
|
||||
"target": "https://bookwyrm.social/user/mouse/shelf/to-read",
|
||||
"@context": "https://www.w3.org/ns/activitystreams"
|
||||
|
|
|
@ -65,6 +65,7 @@ class ReadingViews(TestCase):
|
|||
def test_start_reading_reshelf(self):
|
||||
''' begin a book '''
|
||||
to_read_shelf = self.local_user.shelf_set.get(identifier='to-read')
|
||||
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')
|
||||
|
|
|
@ -57,6 +57,7 @@ class StatusViews(TestCase):
|
|||
view = views.CreateStatus.as_view()
|
||||
user = models.User.objects.create_user(
|
||||
'rat', 'rat@rat.com', 'password', local=True)
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
parent = models.Status.objects.create(
|
||||
content='parent status', user=self.local_user)
|
||||
form = forms.ReplyForm({
|
||||
|
@ -219,6 +220,7 @@ class StatusViews(TestCase):
|
|||
def test_handle_delete_status(self):
|
||||
''' marks a status as deleted '''
|
||||
view = views.DeleteStatus.as_view()
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
status = models.Status.objects.create(
|
||||
user=self.local_user, content='hi')
|
||||
self.assertFalse(status.deleted)
|
||||
|
|
|
@ -39,6 +39,7 @@ class TagViews(TestCase):
|
|||
def test_tag_page(self):
|
||||
''' there are so many views, this just makes sure it LOADS '''
|
||||
view = views.Tag.as_view()
|
||||
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)
|
||||
|
@ -82,6 +83,7 @@ class TagViews(TestCase):
|
|||
def test_untag(self):
|
||||
''' remove a tag from a book '''
|
||||
view = views.RemoveTag.as_view()
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue