def _fix_css_urls(self, page_instruction, css_source): """ When we are rolling CSS files up the are placed in the root of the cache directory. This breaks url values like url(../img/logo.gif). To fix this, we need to manipulate the url values and provide a corrected URL. """ if 'static' in page_instruction: template_name = page_instruction['static'] elif 'inline' in page_instruction: template_name = page_instruction['inline'] return cssimgreplace.relative_replace( css_source, os.path.dirname(template_name), self.cache_url)
def test_will_replace_url_values(): result = cssimgreplace.relative_replace(RAW, "dummyapp/page/media/css/", "http://testserver/media/cfcache/out/") assert result == EXPECTED