bokeh.application.application.Application

Here are the examples of the python api bokeh.application.application.Application taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

11 Examples 7

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_empty(self):
        a = baa.Application()
        doc = a.create_document()
        assert not doc.roots

    def test_invalid_kwarg(self):

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_one_handler(self):
        a = baa.Application()
        def add_roots(doc):
            doc.add_root(AnotherModelInTestApplication())
            doc.add_root(SomeModelInTestApplication())
        handler = FunctionHandler(add_roots)
        a.add(handler)
        doc = a.create_document()
        assert len(doc.roots) == 2

    def test_two_handlers(self):

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_two_handlers(self):
        a = baa.Application()
        def add_roots(doc):
            doc.add_root(AnotherModelInTestApplication())
            doc.add_root(SomeModelInTestApplication())
        def add_one_root(doc):
            doc.add_root(AnotherModelInTestApplication())
        handler = FunctionHandler(add_roots)
        a.add(handler)
        handler2 = FunctionHandler(add_one_root)
        a.add(handler2)
        doc = a.create_document()
        assert len(doc.roots) == 3

    def test_failed_handler(self, caplog):

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_failed_handler(self, caplog):
        a = baa.Application()
        handler = CodeHandler(filename="junk", source="bad(")
        a.add(handler)
        d = Document()
        with caplog.at_level(logging.ERROR):
            assert len(caplog.records) == 0
            a.initialize_document(d)
            assert len(caplog.records) == 1

    def test_no_static_path(self):

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_no_static_path(self):
        a = baa.Application()
        def add_roots(doc):
            doc.add_root(AnotherModelInTestApplication())
            doc.add_root(SomeModelInTestApplication())
        def add_one_root(doc):
            doc.add_root(AnotherModelInTestApplication())
        handler = FunctionHandler(add_roots)
        a.add(handler)
        handler2 = FunctionHandler(add_one_root)
        a.add(handler2)
        assert a.static_path == None

    def test_static_path(self):

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_static_path(self):
        a = baa.Application()
        def add_roots(doc):
            doc.add_root(AnotherModelInTestApplication())
            doc.add_root(SomeModelInTestApplication())
        def add_one_root(doc):
            doc.add_root(AnotherModelInTestApplication())
        handler = FunctionHandler(add_roots)
        handler._static = "foo"
        a.add(handler)
        handler2 = FunctionHandler(add_one_root)
        a.add(handler2)
        assert a.static_path == "foo"

    def test_excess_static_path(self):

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_excess_static_path(self):
        a = baa.Application()
        def add_roots(doc):
            doc.add_root(AnotherModelInTestApplication())
            doc.add_root(SomeModelInTestApplication())
        def add_one_root(doc):
            doc.add_root(AnotherModelInTestApplication())
        handler = FunctionHandler(add_roots)
        handler._static = "foo"
        a.add(handler)
        handler2 = FunctionHandler(add_one_root)
        handler2._static = "bar"
        with pytest.raises(RuntimeError) as e:
            a.add(handler2)
        assert "More than one static path" in str(e)

    @mock.patch('bokeh.document.document.check_integrity')

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_application_validates_document_by_default(self, check_integrity):
        a = baa.Application()
        d = Document()
        d.add_root(figure())
        a.initialize_document(d)
        assert check_integrity.called

    @mock.patch('bokeh.document.document.check_integrity')

3 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_application_doesnt_validate_document_due_to_env_var(self, check_integrity, monkeypatch):
        monkeypatch.setenv("BOKEH_VALIDATE_DOC", "false")
        a = baa.Application()
        d = Document()
        d.add_root(figure())
        a.initialize_document(d)
        assert not check_integrity.called

#-----------------------------------------------------------------------------
# Dev API
#-----------------------------------------------------------------------------

class Test_ServerContext(object):

3 View Source File : test_showing.py
License : MIT License
Project Creator : rthorst

def test_show_with_app(mock_run_notebook_hook):
    curstate().reset()
    app = Application()
    output_notebook()
    bis.show(app, notebook_url="baz")
    assert curstate().notebook_type == "jupyter"
    assert mock_run_notebook_hook.call_count == 1
    assert mock_run_notebook_hook.call_args[0][0] == curstate().notebook_type
    assert mock_run_notebook_hook.call_args[0][1:] == ("app", app, curstate(), "baz")
    assert mock_run_notebook_hook.call_args[1] == {}

@patch('bokeh.io.showing._show_with_state')

0 View Source File : test_application.py
License : MIT License
Project Creator : rthorst

    def test_invalid_kwarg(self):
        with pytest.raises(TypeError):
            baa.Application(junk="foo")

    def test_one_handler(self):