Fix tests

This commit is contained in:
Joachim 2021-08-04 17:39:46 +02:00
parent 7a716db48a
commit 60e805ac2b
2 changed files with 5 additions and 5 deletions

View file

@ -423,13 +423,13 @@ class ImageField(ActivitypubFieldMixin, models.ImageField):
}
)
def get_absolute_url(self, instance):
def get_absolute_url(self, value):
"""returns an absolute URL for the image"""
value = getattr(instance, self.name)
if value is None:
name = getattr(value, self.name)
if name is None:
return
url = filepath_to_uri(value)
url = filepath_to_uri(name)
if url is not None:
url = url.lstrip("/")
url = urljoin(MEDIA_FULL_URL, url)

View file

@ -429,7 +429,7 @@ class ActivitypubFields(TestCase):
def test_image_serialize(self):
"""make sure we're creating sensible image paths"""
ValueMock = namedtuple("ValueMock", ("url"))
value_mock = ValueMock("/images/fish.jpg")
value_mock = ValueMock("https://your.domain.here/images/fish.jpg")
result = fields.image_serializer(value_mock, "hello")
self.assertEqual(result.type, "Document")
self.assertEqual(result.url, "https://your.domain.here/images/fish.jpg")