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

View file

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