Skip to content

Commit

Permalink
Merge branch 'feature/test-super' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantomas42 committed Jul 20, 2014
2 parents f0dc32c + 35076b0 commit eb64128
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions app_namespace/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class LoaderTestCase(TestCase):
maxDiff = None

def test_load_template(self):
app_namespace_loader = Loader()
Expand Down Expand Up @@ -60,7 +59,7 @@ def test_load_template_source_empty_namespace(self):
app_namespace_loader.load_template_source,
':template')

def test_dotted_namespace(self):
def test_load_template_source_dotted_namespace(self):
app_namespace_loader = Loader()

template_short = app_namespace_loader.load_template_source(
Expand All @@ -70,6 +69,10 @@ def test_dotted_namespace(self):

self.assertEquals(template_short[0], template_dotted[0])


class TemplateTestCase(TestCase):
maxDiff = None

def test_extend_and_override(self):
"""
Here we simulate the existence of a template
Expand Down Expand Up @@ -132,3 +135,27 @@ def test_extend_empty_namespace(self):

self.assertTrue(mark in template_namespace)
self.assertTrue(mark_title in template_namespace)

def test_extend_with_super(self):
"""
Here we simulate the existence of a template
named admin/base_site.html on the filesystem
overriding the title markup of the template
with a {{ super }}.
"""
context = Context({})
mark_ok = '<title> | Django site admin - APP NAMESPACE</title>'
mark_ko = '<title> - APP NAMESPACE</title>'

template_directory = Template(
'{% extends "admin/base.html" %}'
'{% block title %}{{ block.super }} - APP NAMESPACE{% endblock %}'
).render(context)

template_namespace = Template(
'{% extends "admin:admin/base_site.html" %}'
'{% block title %}{{ block.super }} - APP NAMESPACE{% endblock %}'
).render(context)

self.assertTrue(mark_ok in template_namespace)
self.assertTrue(mark_ko in template_directory)

0 comments on commit eb64128

Please sign in to comment.