def test_set_related_field(self): ''' celery task to add back-references to created objects ''' status = models.Status.objects.create( content='test status', user=self.user, ) data = { 'url': 'http://www.example.com/image.jpg', 'name': 'alt text', 'type': 'Image', } responses.add(responses.GET, 'http://www.example.com/image.jpg', body=self.image_data, status=200) set_related_field('Image', 'Status', 'status', status.remote_id, data) self.assertIsInstance(status.attachments.first(), models.Image) self.assertIsNotNone(status.attachments.first().image)
def test_set_related_field(self, _): """celery task to add back-references to created objects""" with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): status = models.Status.objects.create( content="test status", user=self.user, ) data = { "url": "http://www.example.com/image.jpg", "name": "alt text", "type": "Document", } responses.add( responses.GET, "http://www.example.com/image.jpg", body=self.image_data, status=200, ) set_related_field("Image", "Status", "status", status.remote_id, data) self.assertIsInstance(status.attachments.first(), models.Image) self.assertIsNotNone(status.attachments.first().image)