def process_external_link_field(field): # Convert any HTTP image links to S3 to HTTPS. # noop if AWS_STORAGE_BUCKET_NAME is not set if getattr(settings, 'AWS_STORAGE_BUCKET_NAME', None): field = convert_http_image_links(field, [ (http_s3_url_prefix(), https_s3_url_prefix()), ]) # Add appropriate markup to all links in HTML. field = parse_links(field).encode(formatter=None) return field
def test_http_s3_url_prefix_no_setting(self): with self.settings(AWS_STORAGE_BUCKET_NAME=None): with self.assertRaises(RuntimeError): http_s3_url_prefix()
def test_http_s3_url_prefix(self): with self.settings(AWS_STORAGE_BUCKET_NAME='foo.bucket'): self.assertEqual( http_s3_url_prefix(), 'http://foo.bucket/' )