~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to turbosimpletal/tests/test_zpt.py

tidy up turbosimpletal a bit, add recompilation templates that have changed on
disk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from turbosimpletal import TurboZpt
2
 
from turbogears import controllers
3
 
from turbogears import testutil
4
 
import turbogears
 
2
from turbogears import controllers, expose, testutil
5
3
import cherrypy
6
4
 
7
 
RENDERED="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<html>\n<head>\n<title>%s</title>\n</head>\n<body>\n<div>Hello, %s</div>\n</body>\n</html>"
 
5
RENDERED = u"<html>\n<head>\n<title>%s</title>\n</head>\n<body>\n<div>Hello, %s</div>\n</body>\n</html>"
8
6
 
9
7
def test_template_lookup():
10
8
    tc = TurboZpt()
13
11
    TITLE="test"
14
12
    NAME="World"
15
13
    info = dict(title=TITLE, name=NAME)
16
 
    s = template(**info)
 
14
    s = template.expand(**info)
17
15
    assert s.startswith(RENDERED % (TITLE, NAME))
18
16
 
19
17
class TestRoot(controllers.Root):
 
18
    @expose(html="zpt:turbosimpletal.tests.simple")
20
19
    def index(self, name, title="test"):
21
20
        return dict(name=name, title=title)
22
 
    index = turbogears.expose(html="zpt:turbosimpletal.tests.simple")(index)
23
21
 
24
22
def test_real_life_situation():
25
23
    cherrypy.root = TestRoot()
26
 
    TITLE="test dave"
27
24
    NAME="Dave"
28
25
    testutil.createRequest("/?name=%s" % NAME)
29
 
    print cherrypy.response.body
30
26
    assert cherrypy.response.body[0].startswith(RENDERED % ("test", NAME))