PageRenderTime 15ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/tests/web/test_expose.py

https://bitbucket.org/prologic/circuits/
Python | 35 lines | 24 code | 11 blank | 0 comment | 0 complexity | d0b0fb5fff2c5ac375f13de5c5eb5533 MD5 | raw file
 1from circuits.web import expose, Controller
 2
 3from .helpers import urlopen
 4
 5
 6class Root(Controller):
 7
 8    def index(self):
 9        return "Hello World!"
10
11    @expose("+test")
12    def test(self):
13        return "test"
14
15    @expose("foo+bar", "foo_bar")
16    def foobar(self):
17        return "foobar"
18
19
20def test(webapp):
21    f = urlopen(webapp.server.http.base)
22    s = f.read()
23    assert s == b"Hello World!"
24
25    f = urlopen("%s/+test" % webapp.server.http.base)
26    s = f.read()
27    assert s == b"test"
28
29    f = urlopen("%s/foo+bar" % webapp.server.http.base)
30    s = f.read()
31    assert s == b"foobar"
32
33    f = urlopen("%s/foo_bar" % webapp.server.http.base)
34    s = f.read()
35    assert s == b"foobar"