mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 17:41:08 +00:00
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
|
return tags
|
||||||
|
|
||||||
def field_from_activity(self, value):
|
def field_from_activity(self, value):
|
||||||
|
if not isinstance(value, list):
|
||||||
|
return None
|
||||||
items = []
|
items = []
|
||||||
for link_json in value:
|
for link_json in value:
|
||||||
link = activitypub.Link(**link_json)
|
link = activitypub.Link(**link_json)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from collections import namedtuple
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import responses
|
import responses
|
||||||
|
@ -113,7 +114,9 @@ class ActivitypubFields(TestCase):
|
||||||
'https://example.com/user/mouse',
|
'https://example.com/user/mouse',
|
||||||
json=userdata,
|
json=userdata,
|
||||||
status=200)
|
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
|
# test recieving activity json
|
||||||
value = instance.field_from_activity(userdata)
|
value = instance.field_from_activity(userdata)
|
||||||
|
@ -173,9 +176,10 @@ class ActivitypubFields(TestCase):
|
||||||
'https://example.com/user/mouse',
|
'https://example.com/user/mouse',
|
||||||
json=userdata,
|
json=userdata,
|
||||||
status=200)
|
status=200)
|
||||||
value = instance.field_from_activity(
|
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||||
['https://example.com/user/mouse', 'bleh']
|
value = instance.field_from_activity(
|
||||||
)
|
['https://example.com/user/mouse', 'bleh']
|
||||||
|
)
|
||||||
self.assertIsInstance(value, list)
|
self.assertIsInstance(value, list)
|
||||||
self.assertEqual(len(value), 1)
|
self.assertEqual(len(value), 1)
|
||||||
self.assertIsInstance(value[0], User)
|
self.assertIsInstance(value[0], User)
|
||||||
|
|
Loading…
Reference in a new issue