mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-29 11:30:39 +00:00
Fixes missing book and user objects
This commit is contained in:
parent
4ed713662e
commit
e7f400533e
2 changed files with 15 additions and 9 deletions
|
@ -31,9 +31,6 @@ class BaseActivity(TestCase):
|
|||
# don't try to load the user icon
|
||||
del self.userdata['icon']
|
||||
|
||||
self.book = models.Edition.objects.create(
|
||||
title='Test Edition', remote_id='http://book.com/book')
|
||||
|
||||
image_file = pathlib.Path(__file__).parent.joinpath(
|
||||
'../../static/images/default_avi.jpg')
|
||||
image = Image.open(image_file)
|
||||
|
@ -146,6 +143,8 @@ class BaseActivity(TestCase):
|
|||
content='test status',
|
||||
user=self.user,
|
||||
)
|
||||
book = models.Edition.objects.create(
|
||||
title='Test Edition', remote_id='http://book.com/book')
|
||||
update_data = activitypub.Note(**status.to_activity())
|
||||
update_data.tag = [
|
||||
{
|
||||
|
@ -161,7 +160,7 @@ class BaseActivity(TestCase):
|
|||
]
|
||||
update_data.to_model(models.Status, instance=status)
|
||||
self.assertEqual(status.mention_users.first(), self.user)
|
||||
self.assertEqual(status.mention_books.first(), self.book)
|
||||
self.assertEqual(status.mention_books.first(), book)
|
||||
|
||||
|
||||
@responses.activate
|
||||
|
|
|
@ -170,12 +170,19 @@ class BaseModel(TestCase):
|
|||
''' attempt to match a remote id to an object in the db '''
|
||||
# uses a different remote id scheme
|
||||
# this isn't really part of this test directly but it's helpful to state
|
||||
self.assertEqual(self.book.origin_id, 'http://book.com/book')
|
||||
self.assertNotEqual(self.book.remote_id, 'http://book.com/book')
|
||||
book = models.Edition.objects.create(
|
||||
title='Test Edition', remote_id='http://book.com/book')
|
||||
user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword', local=True)
|
||||
user.remote_id = 'http://example.com/a/b'
|
||||
user.save()
|
||||
|
||||
self.assertEqual(book.origin_id, 'http://book.com/book')
|
||||
self.assertNotEqual(book.remote_id, 'http://book.com/book')
|
||||
|
||||
# uses subclasses
|
||||
models.Comment.objects.create(
|
||||
user=self.user, content='test status', book=self.book, \
|
||||
user=user, content='test status', book=book, \
|
||||
remote_id='https://comment.net')
|
||||
|
||||
result = models.User.find_existing_by_remote_id('hi')
|
||||
|
@ -183,12 +190,12 @@ class BaseModel(TestCase):
|
|||
|
||||
result = models.User.find_existing_by_remote_id(
|
||||
'http://example.com/a/b')
|
||||
self.assertEqual(result, self.user)
|
||||
self.assertEqual(result, user)
|
||||
|
||||
# test using origin id
|
||||
result = models.Edition.find_existing_by_remote_id(
|
||||
'http://book.com/book')
|
||||
self.assertEqual(result, self.book)
|
||||
self.assertEqual(result, book)
|
||||
|
||||
# test subclass match
|
||||
result = models.Status.find_existing_by_remote_id(
|
||||
|
|
Loading…
Reference in a new issue