forked from mirrors/bookwyrm
Patches celery call in field tests and fixes tag field
This commit is contained in:
parent
0a576c325c
commit
d0c1a68df6
2 changed files with 10 additions and 4 deletions
|
@ -179,6 +179,8 @@ class TagField(ManyToManyField):
|
|||
return tags
|
||||
|
||||
def field_from_activity(self, value):
|
||||
if not isinstance(value, list):
|
||||
return None
|
||||
items = []
|
||||
for link_json in value:
|
||||
link = activitypub.Link(**link_json)
|
||||
|
|
|
@ -4,6 +4,7 @@ from collections import namedtuple
|
|||
import json
|
||||
import pathlib
|
||||
import re
|
||||
from unittest.mock import patch
|
||||
|
||||
from PIL import Image
|
||||
import responses
|
||||
|
@ -113,7 +114,9 @@ class ActivitypubFields(TestCase):
|
|||
'https://example.com/user/mouse',
|
||||
json=userdata,
|
||||
status=200)
|
||||
value = instance.field_from_activity('https://example.com/user/mouse')
|
||||
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||
value = instance.field_from_activity(
|
||||
'https://example.com/user/mouse')
|
||||
|
||||
# test recieving activity json
|
||||
value = instance.field_from_activity(userdata)
|
||||
|
@ -173,9 +176,10 @@ class ActivitypubFields(TestCase):
|
|||
'https://example.com/user/mouse',
|
||||
json=userdata,
|
||||
status=200)
|
||||
value = instance.field_from_activity(
|
||||
['https://example.com/user/mouse', 'bleh']
|
||||
)
|
||||
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||
value = instance.field_from_activity(
|
||||
['https://example.com/user/mouse', 'bleh']
|
||||
)
|
||||
self.assertIsInstance(value, list)
|
||||
self.assertEqual(len(value), 1)
|
||||
self.assertIsInstance(value[0], User)
|
||||
|
|
Loading…
Reference in a new issue