Пример #1
0
def test_dispatch_return_part():
    p = Part(
        endpoints__foo__func=lambda request, **_: html.div('foo', attrs__class__bar=True).bind(request=request),
        endpoints__bar__func=lambda request, **_: html.div('bar', attrs__class__baz=True),
    )
    r = p.bind(request=req('get', **{'/foo': '7'})).render_to_response()
    assert b'<div class="bar">foo</div>' in r.content

    r = p.bind(request=req('get', **{'/bar': '7'})).render_to_response()
    assert b'<div class="baz">bar</div>' in r.content
Пример #2
0
def test_dispatch_return_http_response():
    p = Part(
        endpoints__foo__func=lambda value, **_: HttpResponse(f'foo {value}'))
    r = p.bind(request=req('get', **{'/foo': '7'})).render_to_response()
    assert r.content == b'foo 7'