Moved tests in correct app test package.
This commit is contained in:
30
compressor/test_settings.py
Normal file
30
compressor/test_settings.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
TEST_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'tests')
|
||||||
|
|
||||||
|
COMPRESS_CACHE_BACKEND = 'locmem://'
|
||||||
|
|
||||||
|
DATABASE_ENGINE = 'sqlite3'
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
'compressor',
|
||||||
|
'django_jenkins',
|
||||||
|
]
|
||||||
|
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
|
MEDIA_ROOT = os.path.join(TEST_DIR, 'media')
|
||||||
|
|
||||||
|
TEMPLATE_DIRS = (
|
||||||
|
# Specifically choose a name that will not be considered
|
||||||
|
# by app_directories loader, to make sure each test uses
|
||||||
|
# a specific template without considering the others.
|
||||||
|
os.path.join(TEST_DIR, 'test_templates'),
|
||||||
|
)
|
||||||
|
|
||||||
|
JENKINS_TASKS = (
|
||||||
|
'django_jenkins.tasks.run_pyflakes',
|
||||||
|
'django_jenkins.tasks.run_pep8',
|
||||||
|
'django_jenkins.tasks.with_coverage',
|
||||||
|
'django_jenkins.tasks.django_tests',
|
||||||
|
)
|
@@ -0,0 +1,16 @@
|
|||||||
|
from compressor.tests.base import (CompressorTestCase, CssMediaTestCase,
|
||||||
|
VerboseTestCase, CacheBackendTestCase)
|
||||||
|
from compressor.tests.filters import (CssTidyTestCase, PrecompilerTestCase,
|
||||||
|
CssMinTestCase, CssAbsolutizingTestCase, CssAbsolutizingTestCaseWithHash,
|
||||||
|
CssDataUriTestCase)
|
||||||
|
from compressor.tests.jinja2ext import TestJinja2CompressorExtension
|
||||||
|
from compressor.tests.offline import (
|
||||||
|
OfflineGenerationBlockSuperTestCase, OfflineGenerationConditionTestCase,
|
||||||
|
OfflineGenerationTemplateTagTestCase, OfflineGenerationTestCaseWithContext,
|
||||||
|
OfflineGenerationTestCaseErrors, OfflineGenerationTestCase)
|
||||||
|
from compressor.tests.parsers import (LxmlParserTests, Html5LibParserTests,
|
||||||
|
BeautifulSoupParserTests, HtmlParserTests)
|
||||||
|
from compressor.tests.signals import PostCompressSignalTestCase
|
||||||
|
from compressor.tests.storages import StorageTestCase
|
||||||
|
from compressor.tests.templatetags import (TemplatetagTestCase,
|
||||||
|
PrecompilerTemplatetagTestCase)
|
||||||
|
@@ -19,7 +19,7 @@ def css_tag(href, **kwargs):
|
|||||||
return template % (href, rendered_attrs)
|
return template % (href, rendered_attrs)
|
||||||
|
|
||||||
|
|
||||||
test_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
test_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
||||||
|
|
||||||
|
|
||||||
class CompressorTestCase(TestCase):
|
class CompressorTestCase(TestCase):
|
@@ -12,8 +12,7 @@ from compressor.utils import find_command
|
|||||||
from compressor.filters.base import CompilerFilter
|
from compressor.filters.base import CompilerFilter
|
||||||
from compressor.filters.cssmin import CSSMinFilter
|
from compressor.filters.cssmin import CSSMinFilter
|
||||||
from compressor.filters.css_default import CssAbsoluteFilter
|
from compressor.filters.css_default import CssAbsoluteFilter
|
||||||
|
from compressor.tests.base import test_dir
|
||||||
from .base import test_dir
|
|
||||||
|
|
||||||
|
|
||||||
class CssTidyTestCase(TestCase):
|
class CssTidyTestCase(TestCase):
|
||||||
@@ -30,7 +29,7 @@ color: black;
|
|||||||
|
|
||||||
CssTidyTestCase = skipIf(
|
CssTidyTestCase = skipIf(
|
||||||
find_command(settings.COMPRESS_CSSTIDY_BINARY) is None,
|
find_command(settings.COMPRESS_CSSTIDY_BINARY) is None,
|
||||||
'CSStidy binary %r not found' % settings.COMPRESS_CSSTIDY_BINARY
|
'CSStidy binary %r not found' % settings.COMPRESS_CSSTIDY_BINARY,
|
||||||
)(CssTidyTestCase)
|
)(CssTidyTestCase)
|
||||||
|
|
||||||
|
|
@@ -5,8 +5,7 @@ from django.test import TestCase
|
|||||||
import jinja2
|
import jinja2
|
||||||
|
|
||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
|
from compressor.tests.base import css_tag
|
||||||
from .base import css_tag
|
|
||||||
|
|
||||||
|
|
||||||
class TestJinja2CompressorExtension(TestCase):
|
class TestJinja2CompressorExtension(TestCase):
|
@@ -14,13 +14,13 @@ from compressor.exceptions import OfflineGenerationError
|
|||||||
from compressor.management.commands.compress import Command as CompressCommand
|
from compressor.management.commands.compress import Command as CompressCommand
|
||||||
from compressor.storage import default_storage
|
from compressor.storage import default_storage
|
||||||
|
|
||||||
from .base import css_tag
|
|
||||||
|
|
||||||
class OfflineTestCaseMixin():
|
class OfflineTestCaseMixin(object):
|
||||||
template_name = "test_compressor_offline.html"
|
template_name = "test_compressor_offline.html"
|
||||||
templates_dir = "" # Change this for each test class, to separate templates
|
|
||||||
expected_hash = "" # Change this for each test class to the expected result
|
|
||||||
verbosity = 0
|
verbosity = 0
|
||||||
|
# Change this for each test class
|
||||||
|
templates_dir = ""
|
||||||
|
expected_hash = ""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._old_compress = settings.COMPRESS_ENABLED
|
self._old_compress = settings.COMPRESS_ENABLED
|
||||||
@@ -62,10 +62,12 @@ class OfflineTestCaseMixin():
|
|||||||
rendered_template = self.template.render(Context(settings.COMPRESS_OFFLINE_CONTEXT))
|
rendered_template = self.template.render(Context(settings.COMPRESS_OFFLINE_CONTEXT))
|
||||||
self.assertEqual(rendered_template, "".join(result) + "\n")
|
self.assertEqual(rendered_template, "".join(result) + "\n")
|
||||||
|
|
||||||
|
|
||||||
class OfflineGenerationBlockSuperTestCase(OfflineTestCaseMixin, TestCase):
|
class OfflineGenerationBlockSuperTestCase(OfflineTestCaseMixin, TestCase):
|
||||||
templates_dir = "test_block_super"
|
templates_dir = "test_block_super"
|
||||||
expected_hash = "7c02d201f69d"
|
expected_hash = "7c02d201f69d"
|
||||||
|
|
||||||
|
|
||||||
class OfflineGenerationConditionTestCase(OfflineTestCaseMixin, TestCase):
|
class OfflineGenerationConditionTestCase(OfflineTestCaseMixin, TestCase):
|
||||||
templates_dir = "test_condition"
|
templates_dir = "test_condition"
|
||||||
expected_hash = "4e3758d50224"
|
expected_hash = "4e3758d50224"
|
||||||
@@ -81,10 +83,12 @@ class OfflineGenerationConditionTestCase(OfflineTestCaseMixin, TestCase):
|
|||||||
self.COMPRESS_OFFLINE_CONTEXT = self.old_offline_context
|
self.COMPRESS_OFFLINE_CONTEXT = self.old_offline_context
|
||||||
super(OfflineGenerationConditionTestCase, self).tearDown()
|
super(OfflineGenerationConditionTestCase, self).tearDown()
|
||||||
|
|
||||||
|
|
||||||
class OfflineGenerationTemplateTagTestCase(OfflineTestCaseMixin, TestCase):
|
class OfflineGenerationTemplateTagTestCase(OfflineTestCaseMixin, TestCase):
|
||||||
templates_dir = "test_templatetag"
|
templates_dir = "test_templatetag"
|
||||||
expected_hash = "a27e1d3a619a"
|
expected_hash = "a27e1d3a619a"
|
||||||
|
|
||||||
|
|
||||||
class OfflineGenerationTestCaseWithContext(OfflineTestCaseMixin, TestCase):
|
class OfflineGenerationTestCaseWithContext(OfflineTestCaseMixin, TestCase):
|
||||||
templates_dir = "test_with_context"
|
templates_dir = "test_with_context"
|
||||||
expected_hash = "5838e2fd66af"
|
expected_hash = "5838e2fd66af"
|
||||||
@@ -99,11 +103,13 @@ class OfflineGenerationTestCaseWithContext(OfflineTestCaseMixin, TestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.COMPRESS_OFFLINE_CONTEXT = self.old_offline_context
|
self.COMPRESS_OFFLINE_CONTEXT = self.old_offline_context
|
||||||
super(OfflineGenerationTestCaseWithContext, self).tearDown()
|
super(OfflineGenerationTestCaseWithContext, self).tearDown()
|
||||||
|
|
||||||
|
|
||||||
class OfflineGenerationTestCaseErrors(OfflineTestCaseMixin, TestCase):
|
class OfflineGenerationTestCaseErrors(OfflineTestCaseMixin, TestCase):
|
||||||
templates_dir = "test_error_handling"
|
templates_dir = "test_error_handling"
|
||||||
expected_hash = "cd8870829421"
|
expected_hash = "cd8870829421"
|
||||||
|
|
||||||
|
|
||||||
class OfflineGenerationTestCase(OfflineTestCaseMixin, TestCase):
|
class OfflineGenerationTestCase(OfflineTestCaseMixin, TestCase):
|
||||||
templates_dir = "basic"
|
templates_dir = "basic"
|
||||||
expected_hash = "f5e179b8eca4"
|
expected_hash = "f5e179b8eca4"
|
@@ -21,8 +21,7 @@ except ImportError:
|
|||||||
from compressor.base import SOURCE_HUNK, SOURCE_FILE
|
from compressor.base import SOURCE_HUNK, SOURCE_FILE
|
||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
from compressor.css import CssCompressor
|
from compressor.css import CssCompressor
|
||||||
|
from compressor.tests.base import CompressorTestCase
|
||||||
from .base import CompressorTestCase
|
|
||||||
|
|
||||||
|
|
||||||
class ParserTestCase(object):
|
class ParserTestCase(object):
|
@@ -1,35 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
|
|
||||||
COMPRESS_CACHE_BACKEND = 'locmem://'
|
|
||||||
|
|
||||||
DATABASE_ENGINE = 'sqlite3'
|
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sites',
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.admin',
|
|
||||||
'django_jenkins',
|
|
||||||
'compressor',
|
|
||||||
'tests',
|
|
||||||
]
|
|
||||||
|
|
||||||
MEDIA_URL = '/media/'
|
|
||||||
|
|
||||||
MEDIA_ROOT = os.path.join(TEST_DIR, 'media')
|
|
||||||
|
|
||||||
TEMPLATE_DIRS = (
|
|
||||||
# Specifically choose a name that will not be considered
|
|
||||||
# by app_directories loader, to make sure each test uses
|
|
||||||
# a specific template without considering the others.
|
|
||||||
os.path.join(TEST_DIR, 'test_templates'),
|
|
||||||
)
|
|
||||||
|
|
||||||
JENKINS_TASKS = (
|
|
||||||
'django_jenkins.tasks.run_pyflakes',
|
|
||||||
'django_jenkins.tasks.run_pep8',
|
|
||||||
'django_jenkins.tasks.with_coverage',
|
|
||||||
'django_jenkins.tasks.django_tests',
|
|
||||||
)
|
|
||||||
|
@@ -8,9 +8,8 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from compressor import base
|
from compressor import base
|
||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
|
from compressor.tests.base import css_tag
|
||||||
from .base import css_tag
|
from compressor.tests.templatetags import render
|
||||||
from .templatetags import render
|
|
||||||
|
|
||||||
|
|
||||||
class StorageTestCase(TestCase):
|
class StorageTestCase(TestCase):
|
@@ -10,8 +10,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from compressor.conf import settings
|
from compressor.conf import settings
|
||||||
from compressor.signals import post_compress
|
from compressor.signals import post_compress
|
||||||
|
from compressor.tests.base import css_tag, test_dir
|
||||||
from .base import css_tag, test_dir
|
|
||||||
|
|
||||||
|
|
||||||
def render(template_string, context_dict=None):
|
def render(template_string, context_dict=None):
|
@@ -1,18 +0,0 @@
|
|||||||
from .base import (CompressorTestCase, CssMediaTestCase, VerboseTestCase,
|
|
||||||
CacheBackendTestCase)
|
|
||||||
from .filters import (CssTidyTestCase, PrecompilerTestCase, CssMinTestCase,
|
|
||||||
CssAbsolutizingTestCase, CssAbsolutizingTestCaseWithHash,
|
|
||||||
CssDataUriTestCase)
|
|
||||||
from .jinja2ext import TestJinja2CompressorExtension
|
|
||||||
from .offline import (
|
|
||||||
OfflineGenerationBlockSuperTestCase,
|
|
||||||
OfflineGenerationConditionTestCase,
|
|
||||||
OfflineGenerationTemplateTagTestCase,
|
|
||||||
OfflineGenerationTestCaseWithContext,
|
|
||||||
OfflineGenerationTestCaseErrors,
|
|
||||||
OfflineGenerationTestCase)
|
|
||||||
from .parsers import (LxmlParserTests, Html5LibParserTests,
|
|
||||||
BeautifulSoupParserTests, HtmlParserTests)
|
|
||||||
from .signals import PostCompressSignalTestCase
|
|
||||||
from .storages import StorageTestCase
|
|
||||||
from .templatetags import TemplatetagTestCase, PrecompilerTemplatetagTestCase
|
|
4
tox.ini
4
tox.ini
@@ -1,9 +1,9 @@
|
|||||||
[testenv]
|
[testenv]
|
||||||
downloadcache = {toxworkdir}/_download/
|
downloadcache = {toxworkdir}/_download/
|
||||||
setenv =
|
setenv =
|
||||||
DJANGO_SETTINGS_MODULE = compressor.tests.settings
|
DJANGO_SETTINGS_MODULE = compressor.test_settings
|
||||||
commands =
|
commands =
|
||||||
{envbindir}/python {envbindir}/django-admin.py jenkins {posargs:tests}
|
{envbindir}/python {envbindir}/django-admin.py jenkins {posargs:compressor}
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
basepython = python2.7
|
basepython = python2.7
|
||||||
|
Reference in New Issue
Block a user