@override_settings(ORIGIN='http://connect.local', EMAIL_SECRET_KEY='abcd')
    def test_email_image_max_width(self):
        image = mommy.make('media.Image', image_width=500, image_height=1000)
        image_url = 'http://connect.local' + reverse(
            'custom_image_version',
            kwargs={'image_uuid': image.uuid, 'image_type': 'display_image'})
        result = email_image_max_width(image, 300, 'style="margin: 0 auto;"')
        self.assertIn(image_url, result)
        self.assertIn('width="300"', result)

        # Since 300 is 60% of 500, we need to use 60% of 1000 as the height
        self.assertIn('height="600"', result)
        # Always make sure border="0" is in the tag!
        self.assertIn('border="0"', result)

        # Make sure that our 'extras' are in the tag, padded by spaces
        self.assertIn(' style="margin: 0 auto;" ', result)
Test the max_width templatetag
dataset/ETHPy150Open ofa/connect/open_connect/mailer/tests/test_templatetags.py/TestEmailImage.test_email_image_max_width