~loggerhead-team/loggerhead/trunk-rich

128.6.55 by Michael Hudson
begin by renaming some things
1
from turbosimpletal import TurboZpt
128.6.67 by Michael Hudson
tidy up turbosimpletal a bit, add recompilation templates that have changed on
2
from turbogears import controllers, expose, testutil
128.6.1 by Michael Hudson
add a lightly hacked copy of turbozpt (it's not much code)
3
import cherrypy
4
128.6.67 by Michael Hudson
tidy up turbosimpletal a bit, add recompilation templates that have changed on
5
RENDERED = u"<html>\n<head>\n<title>%s</title>\n</head>\n<body>\n<div>Hello, %s</div>\n</body>\n</html>"
128.6.1 by Michael Hudson
add a lightly hacked copy of turbozpt (it's not much code)
6
7
def test_template_lookup():
8
    tc = TurboZpt()
128.6.55 by Michael Hudson
begin by renaming some things
9
    template = tc.load_template("turbosimpletal.tests.simple")
128.6.1 by Michael Hudson
add a lightly hacked copy of turbozpt (it's not much code)
10
    assert template
11
    TITLE="test"
12
    NAME="World"
13
    info = dict(title=TITLE, name=NAME)
128.6.67 by Michael Hudson
tidy up turbosimpletal a bit, add recompilation templates that have changed on
14
    s = template.expand(**info)
128.6.57 by Michael Hudson
all tests pass, apart from the revision size limit one
15
    assert s.startswith(RENDERED % (TITLE, NAME))
128.6.1 by Michael Hudson
add a lightly hacked copy of turbozpt (it's not much code)
16
17
class TestRoot(controllers.Root):
128.6.67 by Michael Hudson
tidy up turbosimpletal a bit, add recompilation templates that have changed on
18
    @expose(html="zpt:turbosimpletal.tests.simple")
128.6.1 by Michael Hudson
add a lightly hacked copy of turbozpt (it's not much code)
19
    def index(self, name, title="test"):
20
        return dict(name=name, title=title)
21
22
def test_real_life_situation():
23
    cherrypy.root = TestRoot()
24
    NAME="Dave"
25
    testutil.createRequest("/?name=%s" % NAME)
26
    assert cherrypy.response.body[0].startswith(RENDERED % ("test", NAME))