Exemplo n.º 1
0
def test_testing():
    c.get('/', query_string={'answer': '42'})
    aye(True, hasattr(c, 'data'))
    aye(True, call(isinstance, c.data, unicode))

    aye(True, hasattr(c, 'content_type'))
    aye('==', 'text/html; charset=utf-8', c.content_type)

    aye(True, hasattr(c, 'status_code'))
    aye(True, 200, c.status_code)

    aye(True, hasattr(c, 'headers'))
    aye('in', ('Content-Length', '12'), c.headers.items())

    aye(True, hasattr(c, 'path'))
    aye('==', '/', c.path)

    aye(True, hasattr(c, 'url'))
    aye('==', 'http://localhost/?answer=42', c.url)

    aye(False, hasattr(c, 'answer'))

    raises(AssertionError, lambda: aye('in', u' ответ', 'answer 42'))

    aye('in', 'Hello world!', c.cssselect('p'))
Exemplo n.º 2
0
def test_app():
    aye('==', 'examples.simple', app.import_name)
    aye('==', ('', ''), (app['name'], app['prefix']))

    aye(False, call(hasattr, app, 'jinja'))

    aye('==', 3, call(len, marker.defaults.of(app)))
    aye('==', 3, call(len, marker.init.of(app)))
    aye('==', 1, call(len, marker.pre_request.of(app)))
    aye('==', 1, call(len, marker.post_request.of(app)))
    aye('==', 0, call(len, marker.wrap_handler.of(app)))
    aye('==', 0, call(len, marker.middleware.of(app)))

    aye('==', 0, call(len, app.modules))

    url_rules = list(app.url_rules)
    aye('==', 1, call(len, url_rules))
    aye('==', 'examples.simple.index', url_rules[0].endpoint)
    aye('==', '/', url_rules[0].rule)
Exemplo n.º 3
0
def test_app():
    aye('==', 'examples.modular', app.import_name)
    aye('!=', False, app.jinja)

    aye('==', 3, call(len, app.modules))

    front = app.modules['front']
    blog = app.modules['blog']
    admin = app.modules['admin']

    aye('==', ('front', ''), (front['name'], front['prefix']))
    aye('==', ('blog', ''), (blog['name'], blog['prefix']))
    aye('==', ('admin', 'admin'), (admin['name'], admin['prefix']))

    aye('==', 'examples.modular.front', front.import_name)
    aye('==', 'examples.modular.blog', blog.import_name)
    aye('==', 'examples.modular.admin', admin.import_name)
Exemplo n.º 4
0
def test_app():
    aye('==', 'examples.small', app.import_name)
    aye('!=', False, app.jinja)

    aye('==', 5, call(len, marker.defaults.of(app)))
    aye('==', 5, call(len, marker.init.of(app)))
    aye('==', 2, call(len, app.modules))
    aye('==', 1, call(len, marker.pre_request.of(app)))
    aye('==', 1, call(len, marker.post_request.of(app)))
    aye('==', 1, call(len, marker.wrap_handler.of(app)))
    aye('==', 1, call(len, marker.middleware.of(app)))

    mod = app.modules['']
    aye('==', ('', ''), (mod['name'], mod['prefix']))
    aye('==', 'examples.small.views', mod.import_name)
Exemplo n.º 5
0
def test_client():
    result = c.get('/', code=200, as_tuple=True)
    aye('in', 'PATH_INFO', result[0])
    aye(True, call(isinstance, result[1], app.response_class))