File: test_compressor.py

package info (click to toggle)
python-django-pyscss 2.0.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 376 kB
  • sloc: python: 474; makefile: 20
file content (44 lines) | stat: -rw-r--r-- 1,287 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from django.template import Template, Context

from tests.utils import CollectStaticTestCase


APP2_LINK_TAG = """
{% load static compress %}
{% compress css %}
<link rel="stylesheet" type="text/x-scss" href="{% static 'css/app2.scss' %}">
{% endcompress %}
"""

IMPORT_APP2_STYLE_TAG = """
{% load static compress %}
{% compress css %}
<style type="text/x-scss">
@import "css/app2.scss";
</style>
{% endcompress %}
"""


class CompressorTest(CollectStaticTestCase):
    def test_compressor_can_compile_scss(self):
        actual = Template(APP2_LINK_TAG).render(Context())
        # 4b368862ec8c is the cache key that compressor gives to the compiled
        # version of app2.scss.
        try:
            self.assertIn('4b368862ec8c.css', actual)
        except:
            try:
                self.assertIn('9e26139d725b.css', actual)
            except:
                self.assertIn('7e5e65a8e095.css', actual)

    def test_compressor_can_compile_scss_from_style_tag(self):
        actual = Template(IMPORT_APP2_STYLE_TAG).render(Context())
        try:
            self.assertIn('4b368862ec8c.css', actual)
        except:
            try:
                self.assertIn('9e26139d725b.css', actual)
            except:
                self.assertIn('7e5e65a8e095.css', actual)