-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
BJ Dierkes
committed
Jan 5, 2012
1 parent
3296024
commit a2b13a7
Showing
9 changed files
with
120 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,48 @@ | ||
"""Tests for cement2.ext.ext_genshi.""" | ||
|
||
import random | ||
from nose.tools import with_setup, ok_, eq_, raises | ||
from nose import SkipTest | ||
|
||
from cement2.core import handler, backend, log | ||
from cement2.core import exc, foundation, handler, backend, controller | ||
from cement2 import test_helper as _t | ||
|
||
# create the application | ||
defaults = backend.defaults('myapp') | ||
defaults['base']['extensions'].append('cement2.ext.ext_genshi') | ||
defaults['base']['extensions'].append('genshi') | ||
defaults['base']['output_handler'] = 'genshi' | ||
defaults['genshi'] = dict( | ||
template_module='tests.templates' | ||
) | ||
#app = foundation.lay_cement('myapp', defaults=defaults) | ||
app = _t.prep('myapp', defaults=defaults) | ||
app.setup() | ||
app.setup() | ||
app.argv = [] | ||
app.run() | ||
|
||
|
||
def test_genshi(): | ||
app.argv = ['default'] | ||
|
||
app.run() | ||
res = app.render(dict(foo='bar')) | ||
genshi_res = "foo equals bar" | ||
rando = random.random() | ||
res = app.render(dict(foo=rando), 'test_template.txt') | ||
genshi_res = "foo equals %s" % rando | ||
eq_(res, genshi_res) | ||
|
||
def test_genshi_bad_template(): | ||
res = app.render(dict(foo='bar'), 'bad_template.txt') | ||
|
||
@raises(IOError) | ||
def test_genshi_nonexistent_template(): | ||
res = app.render(dict(foo='bar'), 'missing_template.txt') | ||
|
||
@raises(exc.CementRuntimeError) | ||
def test_genshi_none_template(): | ||
try: | ||
res = app.render(dict(foo='bar'), None) | ||
except exc.CementRuntimeError as e: | ||
eq_(e.msg, "Invalid template 'None'.") | ||
raise | ||
|
||
@raises(exc.CementRuntimeError) | ||
def test_genshi_bad_module(): | ||
app.config.set('genshi', 'template_module', 'this_is_a_bogus_module') | ||
res = app.render(dict(foo='bar'), 'bad_template.txt') |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo equals ${foo} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters