def test_invalid_resources_param(self) -> None: with pytest.raises(ValueError): bes.server_document(url="http://localhost:8081/foo/bar/sliders", resources=123) with pytest.raises(ValueError): bes.server_document(url="http://localhost:8081/foo/bar/sliders", resources="whatever")
def test_script_attrs_arguments_provided(self): r = bes.server_document(arguments=dict(foo=10)) assert 'foo=10' in r html = bs4.BeautifulSoup(r, "lxml") scripts = html.findAll(name='script') assert len(scripts) == 1 attrs = scripts[0].attrs assert set(attrs) == set(['src', 'id']) divid = attrs['id'] src = "%s/autoload.js?bokeh-autoload-element=%s&bokeh-absolute-url=%s&foo=10" % \ ("http://localhost:5006", divid, "http://localhost:5006") assert attrs == {'id': divid, 'src': src}
def test_script_attrs_url_provided(self) -> None: r = bes.server_document(url="http://localhost:8081/foo/bar/sliders", relative_urls=True) assert 'bokeh-app-path=/foo/bar/sliders' in r html = bs4.BeautifulSoup(r, "html.parser") scripts = html.findAll(name='script') assert len(scripts) == 1 script = scripts[0] attrs = script.attrs assert list(attrs) == ['id'] divid = attrs['id'] request = "xhr.open('GET', \"%s/autoload.js?bokeh-autoload-element=%s&bokeh-app-path=/foo/bar/sliders\", true);" % \ ("http://localhost:8081/foo/bar/sliders", divid) assert request in script.string
def test_script_attrs_arguments_provided(self) -> None: r = bes.server_document(arguments=dict(foo=10)) assert 'foo=10' in r html = bs4.BeautifulSoup(r, "html.parser") scripts = html.findAll(name='script') assert len(scripts) == 1 script = scripts[0] attrs = script.attrs assert list(attrs) == ['id'] divid = attrs['id'] request = "xhr.open('GET', \"%s/autoload.js?bokeh-autoload-element=%s&bokeh-absolute-url=%s&foo=10\", true);" % \ ("http://localhost:5006", divid, "http://localhost:5006") assert request in script.string
def test_script_attrs_url_provided_absolute_resources(self): r = bes.server_document(url="http://localhost:8081/foo/bar/sliders") assert 'bokeh-app-path=/foo/bar/sliders' in r assert 'bokeh-absolute-url=http://localhost:8081/foo/bar/sliders' in r html = bs4.BeautifulSoup(r, "lxml") scripts = html.findAll(name='script') assert len(scripts) == 1 attrs = scripts[0].attrs assert set(attrs) == set(['src', 'id']) divid = attrs['id'] src = "%s/autoload.js?bokeh-autoload-element=%s&bokeh-app-path=/foo/bar/sliders&bokeh-absolute-url=%s" % \ ("http://localhost:8081/foo/bar/sliders", divid, "http://localhost:8081/foo/bar/sliders") assert attrs == {'id': divid, 'src': src}
def test_script_attrs_url_provided_absolute_resources(self) -> None: r = bes.server_document(url="http://localhost:8081/foo/bar/sliders") assert 'bokeh-app-path=/foo/bar/sliders' in r assert 'bokeh-absolute-url=http://localhost:8081/foo/bar/sliders' in r html = bs4.BeautifulSoup(r, "lxml") scripts = html.findAll(name='script') assert len(scripts) == 1 script = scripts[0] attrs = script.attrs assert list(attrs) == ['id'] divid = attrs['id'] request = "xhr.open('GET', \"%s/autoload.js?bokeh-autoload-element=%s&bokeh-app-path=/foo/bar/sliders&bokeh-absolute-url=%s\", true);" % \ ("http://localhost:8081/foo/bar/sliders", divid, "http://localhost:8081/foo/bar/sliders") assert request in script.text
def test_script_attrs_arguments_provided(self): r = bes.server_document(arguments=dict(foo=10)) assert 'foo=10' in r html = bs4.BeautifulSoup(r, "lxml") scripts = html.findAll(name='script') assert len(scripts) == 1 attrs = scripts[0].attrs assert set(attrs) == set([ 'src', 'id' ]) divid = attrs['id'] src = "%s/autoload.js?bokeh-autoload-element=%s&bokeh-absolute-url=%s&foo=10" % \ ("http://localhost:5006", divid, "http://localhost:5006") assert attrs == { 'id' : divid, 'src' : src }
def test_script_attrs_url_provided(self): r = bes.server_document(url="http://localhost:8081/foo/bar/sliders", relative_urls=True) assert 'bokeh-app-path=/foo/bar/sliders' in r html = bs4.BeautifulSoup(r, "lxml") scripts = html.findAll(name='script') assert len(scripts) == 1 attrs = scripts[0].attrs assert set(attrs) == set([ 'src', 'id' ]) divid = attrs['id'] src = "%s/autoload.js?bokeh-autoload-element=%s&bokeh-app-path=/foo/bar/sliders" % \ ("http://localhost:8081/foo/bar/sliders", divid) assert attrs == { 'id' : divid, 'src' : src }
def test_general(self): r = bes.server_document(url="http://localhost:8081/foo/bar/sliders") assert 'bokeh-app-path=/foo/bar/sliders' in r assert 'bokeh-absolute-url=http://localhost:8081/foo/bar/sliders' in r html = bs4.BeautifulSoup(r, "lxml") scripts = html.findAll(name='script') assert len(scripts) == 1 attrs = scripts[0].attrs assert set(attrs), set([ 'src', 'id' ]) divid = attrs['id'] src = "%s/autoload.js?bokeh-autoload-element=%s&bokeh-app-path=/foo/bar/sliders&bokeh-absolute-url=%s" % \ ("http://localhost:8081/foo/bar/sliders", divid, "http://localhost:8081/foo/bar/sliders") assert attrs == { 'id' : divid, 'src' : src }
def test_script_attrs_url_provided(self): r = bes.server_document(url="http://localhost:8081/foo/bar/sliders", relative_urls=True) assert 'bokeh-app-path=/foo/bar/sliders' in r html = bs4.BeautifulSoup(r, "lxml") scripts = html.findAll(name='script') assert len(scripts) == 1 attrs = scripts[0].attrs assert set(attrs) == set( ['src', 'data-bokeh-doc-id', 'data-bokeh-model-id', 'id']) divid = attrs['id'] src = "%s/autoload.js?bokeh-autoload-element=%s&bokeh-app-path=/foo/bar/sliders" % \ ("http://localhost:8081/foo/bar/sliders", divid) assert attrs == { 'data-bokeh-doc-id': '', 'data-bokeh-model-id': '', 'id': divid, 'src': src }
def test_resources_none(self): r = bes.server_document(url="http://localhost:8081/foo/bar/sliders", resources=None) assert 'resources=none' in r
def test_resources_default_is_implicit(self): r = bes.server_document(url="http://localhost:8081/foo/bar/sliders", resources="default") assert 'resources=' not in r
def test_invalid_resources_param(self): with pytest.raises(ValueError): bes.server_document(url="http://localhost:8081/foo/bar/sliders", resources=123) with pytest.raises(ValueError): bes.server_document(url="http://localhost:8081/foo/bar/sliders", resources="whatever")
def test_resources_none(self) -> None: r = bes.server_document(url="http://localhost:8081/foo/bar/sliders", resources=None) assert 'resources=none' in r
def test_resources_default_is_implicit(self) -> None: r = bes.server_document(url="http://localhost:8081/foo/bar/sliders", resources="default") assert 'resources=' not in r