Example #1
0
def test_auth_provider() -> None:
    bt = tornado.BokehTornado(applications={})
    assert isinstance(bt.auth_provider, NullAuth)

    class FakeAuth:
        get_user = "******"
        endpoints = []
    bt = tornado.BokehTornado(applications={}, auth_provider=FakeAuth)
    assert bt.auth_provider is FakeAuth
Example #2
0
def test_default_app_paths() -> None:
    app = Application()
    t = tornado.BokehTornado({}, "", [])
    assert t.app_paths == set()

    t = tornado.BokehTornado({"/": app}, "", [])
    assert t.app_paths == {"/"}

    t = tornado.BokehTornado({"/": app, "/foo": app}, "", [])
    assert t.app_paths == {"/", "/foo"}
Example #3
0
def test_websocket_compression_level() -> None:
    app = Application()
    t = tornado.BokehTornado({"/": app}, websocket_compression_level=2,
                             websocket_compression_mem_level=3)
    ws_rules = [rule for rule in t.wildcard_router.rules if issubclass(rule.target, WSHandler)]
    assert len(ws_rules) == 1
    ws_rule = ws_rules[0]
    assert ws_rule.target_kwargs.get('compression_level') == 2
    assert ws_rule.target_kwargs.get('mem_level') == 3
Example #4
0
def test_websocket_max_message_size_bytes() -> None:
    app = Application()
    t = tornado.BokehTornado({"/": app},
                             websocket_max_message_size_bytes=12345)
    assert t.settings['websocket_max_message_size'] == 12345
Example #5
0
def test_xsrf_cookies() -> None:
    bt = tornado.BokehTornado(applications={})
    assert not bt.settings['xsrf_cookies']

    bt = tornado.BokehTornado(applications={}, xsrf_cookies=True)
    assert bt.settings['xsrf_cookies']