diff options
Diffstat (limited to 'test/test_tgplugin.py')
-rw-r--r-- | test/test_tgplugin.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/test_tgplugin.py b/test/test_tgplugin.py new file mode 100644 index 0000000..701eb94 --- /dev/null +++ b/test/test_tgplugin.py @@ -0,0 +1,41 @@ +import unittest + +from mako.ext.turbogears import TGPlugin +from util import flatten_result, result_lines + +tl = TGPlugin(options=dict(directories=['./test_htdocs']), extension='html') + +class TestTGPlugun(unittest.TestCase): + def test_basic(self): + t = tl.load_template('/index.html') + assert result_lines(t.render()) == [ + "this is index" + ] + def test_subdir(self): + t = tl.load_template('/subdir/index.html') + assert result_lines(t.render()) == [ + "this is sub index", + "this is include 2" + + ] + + assert tl.load_template('/subdir/index.html').module_id == '_subdir_index_html' + + def test_basic_dot(self): + t = tl.load_template('index') + assert result_lines(t.render()) == [ + "this is index" + ] + def test_subdir_dot(self): + t = tl.load_template('subdir.index') + assert result_lines(t.render()) == [ + "this is sub index", + "this is include 2" + + ] + + assert tl.load_template('subdir.index').module_id == '_subdir_index_html' + + def test_string(self): + t = tl.load_template('foo', "hello world") + assert t.render() == "hello world" |