~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to turbosimpletal/tests/test_zpt.py

  • Committer: Michael Hudson
  • Date: 2008-06-16 10:03:24 UTC
  • mfrom: (159.1.7 remove_caches)
  • Revision ID: michael.hudson@canonical.com-20080616100324-dyzbdp3xk2i1g34a
merge martin's remove caches branch, which removes the sql revision cache and
the textindexing code.
we still have the files changed cache.
(some further changes by me)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from turbozpt import TurboZpt
2
 
from turbogears import controllers
3
 
from turbogears import testutil
4
 
import turbogears
 
1
from turbosimpletal import TurboZpt
 
2
from turbogears import controllers, expose, testutil
5
3
import cherrypy
6
4
 
7
 
RENDERED="<html>\n<head>\n<title>%s</title>\n</head>\n<body>\n<div>Hello, %s</div>\n</body>\n</html>\n"
 
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()
11
 
    template = tc.load_template("turbozpt.tests.simple")
 
9
    template = tc.load_template("turbosimpletal.tests.simple")
12
10
    assert template
13
11
    TITLE="test"
14
12
    NAME="World"
15
13
    info = dict(title=TITLE, name=NAME)
16
 
    t = template(**info)
17
 
    assert str(t).startswith(RENDERED % (TITLE, NAME))
 
14
    s = template.expand(**info)
 
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:turbozpt.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))