Commit 556578ac authored by Shaun Brady's avatar Shaun Brady

Update tests to use new sha256 hashes

From a previous commit, the md5 function was switched out for sha256.
This commit should fix the tests broken by that change.  Commit includes
a doc text update as well.
parent 2463efdc
......@@ -92,12 +92,12 @@ class Compressor(object):
Returns file path for an output file based on contents.
Returned path is relative to compressor storage's base url, for
example "CACHE/css/e41ba2cc6982.css".
example "CACHE/css/58a8c0714e59.css".
When `basename` argument is provided then file name (without extension)
will be used as a part of returned file name, for example:
get_filepath(content, "my_file.css") -> 'CACHE/css/my_file.e41ba2cc6982.css'
get_filepath(content, "my_file.css") -> 'CACHE/css/my_file.58a8c0714e59.css'
"""
parts = []
if basename:
......
......@@ -57,10 +57,10 @@ class PrecompilerAndAbsoluteFilterTestCase(SimpleTestCase):
def setUp(self):
self.html_orig = '<link rel="stylesheet" href="/static/css/relative_url.css" type="text/css" />'
self.html_link_to_precompiled_css = '<link rel="stylesheet" href="/static/CACHE/css/relative_url.41a74f6d5864.css" type="text/css" />'
self.html_link_to_absolutized_css = '<link rel="stylesheet" href="/static/CACHE/css/relative_url.9b8fd415e521.css" type="text/css" />'
self.html_link_to_precompiled_css = '<link rel="stylesheet" href="/static/CACHE/css/relative_url.e8602322bfa6.css" type="text/css" />'
self.html_link_to_absolutized_css = '<link rel="stylesheet" href="/static/CACHE/css/relative_url.376db5682982.css" type="text/css" />'
self.css_orig = "p { background: url('../img/python.png'); }" # content of relative_url.css
self.css_absolutized = "p { background: url('/static/img/python.png?c2281c83670e'); }"
self.css_absolutized = "p { background: url('/static/img/python.png?ccb38978f900'); }"
def helper(self, enabled, use_precompiler, use_absolute_filter, expected_output):
precompiler = (('text/css', 'compressor.tests.test_base.PassthroughPrecompiler'),) if use_precompiler else ()
......@@ -181,7 +181,7 @@ class CompressorTestCase(SimpleTestCase):
r"cachekey is returning something that doesn't look like r'\w{12}'")
def test_css_return_if_on(self):
output = css_tag('/static/CACHE/css/e41ba2cc6982.css')
output = css_tag('/static/CACHE/css/58a8c0714e59.css')
self.assertEqual(output, self.css_node.output().strip())
def test_js_split(self):
......@@ -208,17 +208,17 @@ class CompressorTestCase(SimpleTestCase):
self.assertEqual(out, list(self.js_node.hunks()))
def test_js_output(self):
out = '<script type="text/javascript" src="/static/CACHE/js/d728fc7f9301.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/74e158ccb432.js"></script>'
self.assertEqual(out, self.js_node.output())
def test_js_override_url(self):
self.js_node.context.update({'url': 'This is not a url, just a text'})
out = '<script type="text/javascript" src="/static/CACHE/js/d728fc7f9301.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/74e158ccb432.js"></script>'
self.assertEqual(out, self.js_node.output())
def test_css_override_url(self):
self.css_node.context.update({'url': 'This is not a url, just a text'})
output = css_tag('/static/CACHE/css/e41ba2cc6982.css')
output = css_tag('/static/CACHE/css/58a8c0714e59.css')
self.assertEqual(output, self.css_node.output().strip())
@override_settings(COMPRESS_PRECOMPILERS=(), COMPRESS_ENABLED=False)
......@@ -226,22 +226,22 @@ class CompressorTestCase(SimpleTestCase):
self.assertEqualCollapsed(self.js, self.js_node.output())
def test_js_return_if_on(self):
output = '<script type="text/javascript" src="/static/CACHE/js/d728fc7f9301.js"></script>'
output = '<script type="text/javascript" src="/static/CACHE/js/74e158ccb432.js"></script>'
self.assertEqual(output, self.js_node.output())
@override_settings(COMPRESS_OUTPUT_DIR='custom')
def test_custom_output_dir1(self):
output = '<script type="text/javascript" src="/static/custom/js/d728fc7f9301.js"></script>'
output = '<script type="text/javascript" src="/static/custom/js/74e158ccb432.js"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
@override_settings(COMPRESS_OUTPUT_DIR='')
def test_custom_output_dir2(self):
output = '<script type="text/javascript" src="/static/js/d728fc7f9301.js"></script>'
output = '<script type="text/javascript" src="/static/js/74e158ccb432.js"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
@override_settings(COMPRESS_OUTPUT_DIR='/custom/nested/')
def test_custom_output_dir3(self):
output = '<script type="text/javascript" src="/static/custom/nested/js/d728fc7f9301.js"></script>'
output = '<script type="text/javascript" src="/static/custom/nested/js/74e158ccb432.js"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
@override_settings(COMPRESS_PRECOMPILERS=(
......
......@@ -77,7 +77,7 @@ class TestJinja2CompressorExtension(TestCase):
<link rel="stylesheet" href="{{ STATIC_URL }}css/two.css" type="text/css" charset="utf-8">
{% endcompress %}""")
context = {'STATIC_URL': settings.COMPRESS_URL}
out = css_tag("/static/CACHE/css/e41ba2cc6982.css")
out = css_tag("/static/CACHE/css/58a8c0714e59.css")
self.assertEqual(out, template.render(context))
def test_nonascii_css_tag(self):
......@@ -86,7 +86,7 @@ class TestJinja2CompressorExtension(TestCase):
<style type="text/css">p { border:5px solid green;}</style>
{% endcompress %}""")
context = {'STATIC_URL': settings.COMPRESS_URL}
out = css_tag("/static/CACHE/css/799f6defe43c.css")
out = css_tag("/static/CACHE/css/4263023f49d6.css")
self.assertEqual(out, template.render(context))
def test_js_tag(self):
......@@ -95,7 +95,7 @@ class TestJinja2CompressorExtension(TestCase):
<script type="text/javascript" charset="utf-8">obj.value = "value";</script>
{% endcompress %}""")
context = {'STATIC_URL': settings.COMPRESS_URL}
out = '<script type="text/javascript" src="/static/CACHE/js/d728fc7f9301.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/74e158ccb432.js"></script>'
self.assertEqual(out, template.render(context))
def test_nonascii_js_tag(self):
......@@ -104,7 +104,7 @@ class TestJinja2CompressorExtension(TestCase):
<script type="text/javascript" charset="utf-8">var test_value = "\u2014";</script>
{% endcompress %}""")
context = {'STATIC_URL': settings.COMPRESS_URL}
out = '<script type="text/javascript" src="/static/CACHE/js/d34f30e02e70.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/a18195c6ae48.js"></script>'
self.assertEqual(out, template.render(context))
def test_nonascii_latin1_js_tag(self):
......@@ -113,7 +113,7 @@ class TestJinja2CompressorExtension(TestCase):
<script type="text/javascript">var test_value = "\u2014";</script>
{% endcompress %}""")
context = {'STATIC_URL': settings.COMPRESS_URL}
out = '<script type="text/javascript" src="/static/CACHE/js/a830bddd3636.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/f64debbd8878.js"></script>'
self.assertEqual(out, template.render(context))
def test_css_inline(self):
......@@ -143,6 +143,6 @@ class TestJinja2CompressorExtension(TestCase):
'<style type="text/css">'
'/* русский текст */'
'</style>{% endcompress %}')
out = '<link rel="stylesheet" href="/static/CACHE/css/b2cec0f8cb24.css" type="text/css" />'
out = '<link rel="stylesheet" href="/static/CACHE/css/c836c9caed5c.css" type="text/css" />'
context = {'STATIC_URL': settings.COMPRESS_URL}
self.assertEqual(out, template.render(context))
......@@ -8,7 +8,7 @@ class TestMtimeCacheCommand(TestCase):
# FIXME: add actual tests, improve the existing ones.
exclusion_patterns = [
'*CACHE*', '*custom*', '*066cd253eada.js', '*d728fc7f9301.js', 'test.txt*'
'*CACHE*', '*custom*', '*066cd253eada.js', '*d728fc7f9301.js', '*74e158ccb432.js', 'test.txt*'
]
def default_ignore(self):
......
This diff is collapsed.
......@@ -41,7 +41,7 @@ class StorageTestCase(TestCase):
{% endcompress %}
"""
context = {'STATIC_URL': settings.COMPRESS_URL}
out = css_tag("/static/CACHE/css/1d4424458f88.css")
out = css_tag("/static/CACHE/css/aca9bcd16bee.css")
self.assertEqual(out, render(template, context))
def test_race_condition_handling(self):
......
......@@ -45,7 +45,7 @@ class TemplatetagTestCase(TestCase):
<style type="text/css">p { border:5px solid green;}</style>
<link rel="stylesheet" href="{{ STATIC_URL }}css/two.css" type="text/css">
{% endcompress %}"""
out = css_tag("/static/CACHE/css/e41ba2cc6982.css")
out = css_tag("/static/CACHE/css/58a8c0714e59.css")
self.assertEqual(out, render(template, self.context))
def test_missing_rel_leaves_empty_result(self):
......@@ -62,7 +62,7 @@ class TemplatetagTestCase(TestCase):
<style type="text/css">p { border:5px solid green;}</style>
<link rel="stylesheet" href="{{ STATIC_URL }}css/two.css" type="text/css">
{% endcompress %}"""
out = css_tag("/static/CACHE/css/e41ba2cc6982.css")
out = css_tag("/static/CACHE/css/58a8c0714e59.css")
self.assertEqual(out, render(template, self.context))
def test_uppercase_rel(self):
......@@ -71,7 +71,7 @@ class TemplatetagTestCase(TestCase):
<style type="text/css">p { border:5px solid green;}</style>
<link rel="StyleSheet" href="{{ STATIC_URL }}css/two.css" type="text/css">
{% endcompress %}"""
out = css_tag("/static/CACHE/css/e41ba2cc6982.css")
out = css_tag("/static/CACHE/css/58a8c0714e59.css")
self.assertEqual(out, render(template, self.context))
def test_nonascii_css_tag(self):
......@@ -80,7 +80,7 @@ class TemplatetagTestCase(TestCase):
<style type="text/css">p { border:5px solid green;}</style>
{% endcompress %}
"""
out = css_tag("/static/CACHE/css/799f6defe43c.css")
out = css_tag("/static/CACHE/css/4263023f49d6.css")
self.assertEqual(out, render(template, self.context))
def test_js_tag(self):
......@@ -89,7 +89,7 @@ class TemplatetagTestCase(TestCase):
<script type="text/javascript">obj.value = "value";</script>
{% endcompress %}
"""
out = '<script type="text/javascript" src="/static/CACHE/js/d728fc7f9301.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/74e158ccb432.js"></script>'
self.assertEqual(out, render(template, self.context))
def test_nonascii_js_tag(self):
......@@ -98,7 +98,7 @@ class TemplatetagTestCase(TestCase):
<script type="text/javascript">var test_value = "\u2014";</script>
{% endcompress %}
"""
out = '<script type="text/javascript" src="/static/CACHE/js/d34f30e02e70.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/a18195c6ae48.js"></script>'
self.assertEqual(out, render(template, self.context))
def test_nonascii_latin1_js_tag(self):
......@@ -107,7 +107,7 @@ class TemplatetagTestCase(TestCase):
<script type="text/javascript">var test_value = "\u2014";</script>
{% endcompress %}
"""
out = '<script type="text/javascript" src="/static/CACHE/js/a830bddd3636.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/f64debbd8878.js"></script>'
self.assertEqual(out, render(template, self.context))
def test_compress_tag_with_illegal_arguments(self):
......@@ -168,11 +168,12 @@ class TemplatetagTestCase(TestCase):
<script type="text/javascript">var tmpl="{% templatetag openblock %} if x == 3 %}x IS 3{% templatetag openblock %} endif %}"</script>
{% endaddtoblock %}{% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %}
"""
out = '<script type="text/javascript" src="/static/CACHE/js/74e008a57789.js"></script>'
out = '<script type="text/javascript" src="/static/CACHE/js/4d88842b99b3.js"></script>'
self.assertEqual(out, render(template, self.context, SekizaiContext))
class PrecompilerTemplatetagTestCase(TestCase):
def setUp(self):
precompiler = os.path.join(test_dir, 'precompiler.py')
python = sys.executable
......@@ -196,7 +197,7 @@ class PrecompilerTemplatetagTestCase(TestCase):
template = """{% load compress %}{% compress js %}
<script type="text/coffeescript"># this is a comment.</script>
{% endcompress %}"""
out = script(src="/static/CACHE/js/82d254e4462a.js")
out = script(src="/static/CACHE/js/fb128b610c3e.js")
self.assertEqual(out, render(template, self.context))
def test_compress_coffeescript_tag_and_javascript_tag(self):
......@@ -204,7 +205,7 @@ class PrecompilerTemplatetagTestCase(TestCase):
<script type="text/coffeescript"># this is a comment.</script>
<script type="text/javascript"># this too is a comment.</script>
{% endcompress %}"""
out = script(src="/static/CACHE/js/07bc3c26db9a.js")
out = script(src="/static/CACHE/js/cf3495aaff6e.js")
self.assertEqual(out, render(template, self.context))
@override_settings(COMPRESS_ENABLED=False)
......@@ -233,7 +234,7 @@ class PrecompilerTemplatetagTestCase(TestCase):
</script>
{% endcompress %}"""
out = script(src="/static/CACHE/js/one.95cfb869eead.js")
out = script(src="/static/CACHE/js/one.4b3570601b8c.js")
self.assertEqual(out, render(template, self.context))
@override_settings(COMPRESS_ENABLED=False)
......@@ -247,9 +248,9 @@ class PrecompilerTemplatetagTestCase(TestCase):
</script>
{% endcompress %}"""
out = '\n'.join([script(src="/static/CACHE/js/one.95cfb869eead.js"),
out = '\n'.join([script(src="/static/CACHE/js/one.4b3570601b8c.js"),
script(scripttype="", src="/static/js/one.js"),
script(src="/static/CACHE/js/one.81a2cd965815.js")])
script(src="/static/CACHE/js/one.8ab93aace8fa.js")])
self.assertEqual(out, render(template, self.context))
......@@ -279,7 +280,7 @@ class PrecompilerTemplatetagTestCase(TestCase):
out = ''.join(['<link rel="stylesheet" type="text/css" href="/static/css/one.css" />',
'<link rel="stylesheet" type="text/css" href="/static/css/two.css" />',
'<link rel="stylesheet" href="/static/CACHE/css/test.5dddc6c2fb5a.css" type="text/css" />'])
'<link rel="stylesheet" href="/static/CACHE/css/test.222f958fb191.css" type="text/css" />'])
self.assertEqual(out, render(template, self.context))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment