Skip to content

Commit

Permalink
Added tests for postprocessors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Obrist committed Oct 22, 2011
1 parent a9a8e7a commit e0405db
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
21 changes: 20 additions & 1 deletion sekizai/tests.py
Expand Up @@ -5,10 +5,18 @@
from django.template.loader import render_to_string
from sekizai.context import SekizaiContext
from sekizai.helpers import validate_template, get_namespaces
from sekizai.templatetags.sekizai_tags import validate_context
from sekizai.templatetags.sekizai_tags import (validate_context,
import_processor)
from unittest import TestCase


def null_processor(data, namespace):
return ''

def namespace_processor(data, namespace):
return namespace


class SettingsOverride(object):
"""
Overrides Django settings within a context and resets them to their inital
Expand Down Expand Up @@ -250,6 +258,17 @@ def test_validate_context(self):
self.assertEqual(validate_context(sekizai_ctx), True)
bits = ['some content', 'more content', 'final content']
self._test('basic.html', bits, ctxclass=template.Context)

def test_post_processor_null(self):
bits = ['header', 'footer']
self._test('processors/null.html', bits)

def test_post_processor_namespace(self):
bits = ['header', 'footer', 'js']
self._test('processors/namespace.html', bits)

def test_import_processor_failfast(self):
self.assertRaises(TypeError, import_processor, 'invalidpath')


class HelperTests(TestCase):
Expand Down
11 changes: 11 additions & 0 deletions test_templates/processors/namespace.html
@@ -0,0 +1,11 @@
{% load sekizai_tags %}

header

{% addtoblock "js" %}
javascript
{% endaddtoblock %}

footer

{% render_block "js" postprocessor "sekizai.tests.namespace_processor" %}
11 changes: 11 additions & 0 deletions test_templates/processors/null.html
@@ -0,0 +1,11 @@
{% load sekizai_tags %}

header

{% addtoblock "js" %}
javascript
{% endaddtoblock %}

footer

{% render_block "js" postprocessor "sekizai.tests.null_processor" %}
15 changes: 0 additions & 15 deletions test_templates/yui.html

This file was deleted.

0 comments on commit e0405db

Please sign in to comment.