From 200adfaa06093358e26fc8fe0960e18077196ba1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 9 Sep 2015 07:01:31 -0400 Subject: [PATCH] A test for optional_include_mako --- .../pipeline_mako/templates/test_exists.html | 2 ++ .../templates/test_optional_include_mako.html | 8 ++++++++ .../djangoapps/pipeline_mako/tests/__init__.py | 0 .../pipeline_mako/tests/test_static_content.py | 16 ++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 common/djangoapps/pipeline_mako/templates/test_exists.html create mode 100644 common/djangoapps/pipeline_mako/templates/test_optional_include_mako.html create mode 100644 common/djangoapps/pipeline_mako/tests/__init__.py create mode 100644 common/djangoapps/pipeline_mako/tests/test_static_content.py diff --git a/common/djangoapps/pipeline_mako/templates/test_exists.html b/common/djangoapps/pipeline_mako/templates/test_exists.html new file mode 100644 index 0000000000..1cc4d19d6c --- /dev/null +++ b/common/djangoapps/pipeline_mako/templates/test_exists.html @@ -0,0 +1,2 @@ +# Only for testing. +

This is test_exists.html

diff --git a/common/djangoapps/pipeline_mako/templates/test_optional_include_mako.html b/common/djangoapps/pipeline_mako/templates/test_optional_include_mako.html new file mode 100644 index 0000000000..b1bb06f806 --- /dev/null +++ b/common/djangoapps/pipeline_mako/templates/test_optional_include_mako.html @@ -0,0 +1,8 @@ +# A test template for optional_include_mako + +<%namespace name='static' file='static_content.html'/> + +

Welcome to test_optional_include_mako.html

+ +<%static:optional_include_mako file="test_exists.html" /> +<%static:optional_include_mako file="definitely_doesnt_exist.html" /> diff --git a/common/djangoapps/pipeline_mako/tests/__init__.py b/common/djangoapps/pipeline_mako/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/common/djangoapps/pipeline_mako/tests/test_static_content.py b/common/djangoapps/pipeline_mako/tests/test_static_content.py new file mode 100644 index 0000000000..f77a5fc216 --- /dev/null +++ b/common/djangoapps/pipeline_mako/tests/test_static_content.py @@ -0,0 +1,16 @@ +""" +Tests of pipeline_mako/templates/static_content.html +""" + +import unittest + +from edxmako.shortcuts import render_to_string + + +class TestStaticContent(unittest.TestCase): + """Tests for static_content.html""" + + def test_optional_include_mako(self): + out = render_to_string("test_optional_include_mako.html", {}) + self.assertIn("Welcome to test_optional_include_mako.html", out) + self.assertIn("This is test_exists.html", out)