Esempio n. 1
0
def test_remaining_url_arg_parser():
    with get(weby.wsgify(simplest.app), u'/joe?times=10') as r:
        assert u'200' in r.status
        assert u'joe' in r.body
        assert u'Hello, joe!' in r.body
        assert len(re.findall(u'joe', r.body)) == 10
        assert u'Hello, joe!' in r.body
Esempio n. 2
0
def test_simplest():
    with get(weby.wsgify(simplest.app), u'/world?times=3') as r:
        assert u'200' in r.status
        body = r.body
        assert u'world' in body
        assert u'Hello, world!' in body
        assert len(re.findall('world', body)) == 3
Esempio n. 3
0
def test_simplest_hello():
    with get(weby.wsgify(simplest.app), '/') as r:
        assert u'200' in r.status
        assert u'world' in r.body
        assert u'Hello, world!' in r.body
        assert u'<br />' in r.body
        assert u'500' not in r.status
        assert u'Error' not in r.status
        assert u'Error' not in r.body
Esempio n. 4
0
def test_static_app():
    content = u'div {\n    color: blue;\n}\n'
    with get(weby.wsgify(standard.app), u'/static/style.css') as r:
        assert content == r.body
Esempio n. 5
0
def test_send_email():
    with difference(lambda:len(send_email.mail_server.sent_email)):
        with get(weby.wsgify(send_email.app), '/static/style.css') as r:
            assert u'200' in r.status
Esempio n. 6
0
def test_layout():
    with get(weby.wsgify(layouts.app), '/hello?name=joe') as r:
        assert u'200' in r.status
        assert u'joe' in r.body
        assert u'Hello, joe!' in r.body
        assert u'<title>' in r.body
Esempio n. 7
0
def test_template():
    with get(weby.wsgify(first_template.app), u'/hello?name=joe') as r:
        assert u'200' in r.status
        assert u'joe' in r.body
        assert u'Hello, joe!' in r.body
Esempio n. 8
0
def test_redirect():
    with get(weby.wsgify(hello.app), '/hello_old/') as r:
        assert u'302' in r.status
        assert u'/hello/' in r.body
Esempio n. 9
0
def test_unicode():
    with get(weby.wsgify(simplest.app), u'/wểrld?times=3') as r:
        assert u'200' in r.status
        assert u'wểrld' in r.body.decode('utf8')
        assert u'Hello, wểrld!' in r.body.decode('utf8')
        assert len(re.findall(u'wểrld', r.body.decode('utf8'))) == 3
Esempio n. 10
0
def test_index():
    with get(weby.wsgify(hello.app), '/') as r:
        assert u'200' in r.status
        assert u'Hello, world!' in r.body