Patches celery call in field tests and fixes tag field

This commit is contained in:
Mouse Reeve 2020-12-07 13:39:05 -08:00
parent 0a576c325c
commit d0c1a68df6
2 changed files with 10 additions and 4 deletions

View file

@ -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)

View file

@ -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,6 +176,7 @@ class ActivitypubFields(TestCase):
'https://example.com/user/mouse',
json=userdata,
status=200)
with patch('bookwyrm.models.user.set_remote_server.delay'):
value = instance.field_from_activity(
['https://example.com/user/mouse', 'bleh']
)