~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/tests/test_templating.py

  • Committer: Michael Hudson
  • Date: 2008-06-20 03:46:24 UTC
  • mfrom: (159.2.51 wsgi-ify)
  • Revision ID: michael.hudson@canonical.com-20080620034624-p46dvwbhppj2pojw
merge wsgi-ify
this removes the dependency on turbogears and cherrypy in favour of one on
paste (http://pythonpaste.org).
it adds a new executable, serve-branches.py, that serves branches following the
structure of the file system, but also converts start-loggerhead.py to serve
things from a loggerhead.conf file the 'old-fashioned' way.

Show diffs side-by-side

added added

removed removed

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