def test_abs_static(self):
        """
        Normally in your templates you do something like this:

            <img src="{{ static('images/logo.png') }}">

        and it'll yield something like this:

            <img src="/static/images/logo.png">

        But if you really want to make it absolute you do this:

            <img src="{{ abs_static('images/logo.png') }}">

        and it should yield something like:

            <img src="https://example.com/static/images/logo.png">

        """
        context = {}
        context['request'] = RequestFactory().get('/')

        absolute_relative_path = self._create_static_file('foo.png', 'data')
        result = abs_static(context, 'foo.png')
        eq_(result, 'http://testserver%s' % absolute_relative_path)
    def test_abs_static(self):
        """
        Normally in your templates you do something like this:

            <img src="{{ static('images/logo.png') }}">

        and it'll yield something like this:

            <img src="/static/images/logo.png">

        But if you really want to make it absolute you do this:

            <img src="{{ abs_static('images/logo.png') }}">

        and it should yield something like:

            <img src="https://example.com/static/images/logo.png">

        """
        context = {}
        context['request'] = RequestFactory().get('/')

        absolute_relative_path = self._create_static_file('foo.png', 'data')
        result = abs_static(context, 'foo.png')
        eq_(result, 'http://testserver%s' % absolute_relative_path)
    def test_abs_static_with_HTTPS_STATIC_URL(self):
        context = {}
        context['request'] = RequestFactory().get('/')

        absolute_relative_path = self._create_static_file('hoo.png', 'data')

        with self.settings(STATIC_URL='https://my.cdn.com/static/'):
            result = abs_static(context, 'hoo.png')
            eq_(result, 'https://my.cdn.com%s' % absolute_relative_path)
    def test_abs_static_with_HTTPS_STATIC_URL(self):
        context = {}
        context['request'] = RequestFactory().get('/')

        absolute_relative_path = self._create_static_file('hoo.png', 'data')

        with self.settings(STATIC_URL='https://my.cdn.com/static/'):
            result = abs_static(context, 'hoo.png')
            eq_(result, 'https://my.cdn.com%s' % absolute_relative_path)
    def test_abs_static_with_STATIC_URL_with_https(self):
        context = {}
        context['request'] = RequestFactory().get('/')
        context['request'].is_secure = lambda: True
        assert context['request'].is_secure()

        absolute_relative_path = self._create_static_file('foo.png', 'data')

        with self.settings(STATIC_URL='//my.cdn.com/static/'):
            result = abs_static(context, 'foo.png')
            eq_(result, 'https://my.cdn.com%s' % absolute_relative_path)
    def test_abs_static_with_STATIC_URL_with_https(self):
        context = {}
        context['request'] = RequestFactory().get('/')
        context['request'].is_secure = lambda: True
        assert context['request'].is_secure()

        absolute_relative_path = self._create_static_file('foo.png', 'data')

        with self.settings(STATIC_URL='//my.cdn.com/static/'):
            result = abs_static(context, 'foo.png')
            eq_(result, 'https://my.cdn.com%s' % absolute_relative_path)