示例#1
0
    def test_js_release_cdn(self, monkeypatch: pytest.MonkeyPatch,
                            driver: WebDriver,
                            test_file_path_and_url: Tuple[str, str],
                            test_plot: figure) -> None:
        monkeypatch.setattr(buv, "__version__", "2.0.0")
        monkeypatch.setattr(resources, "__version__", "2.0.0")
        r = deepcopy(CDN)
        # Skip bokeh-mathjax for older versions
        r.js_components.remove("bokeh-mathjax")
        js, tag = bes.autoload_static(test_plot, r, "some/path")

        page = PAGE.render(js=js, tag=tag)

        path, url = test_file_path_and_url
        with open(path, "w") as f:
            f.write(page)

        driver.get(url)

        scripts = driver.find_elements(By.CSS_SELECTOR, 'head script')
        for x in scripts:
            print(x.get_attribute("src"))
        assert len(scripts) == 4
        for script in scripts:
            assert script.get_attribute("crossorigin") == None
            assert script.get_attribute("integrity") == ""
示例#2
0
 def test_script_attrs(self, test_plot: figure) -> None:
     _, tag = bes.autoload_static(test_plot, CDN, "some/path")
     html = bs4.BeautifulSoup(tag, "html.parser")
     scripts = html.find_all(name='script')
     assert len(scripts) == 1
     attrs = scripts[0].attrs
     assert set(attrs) == {"src", "id"}
     assert attrs["src"] == "some/path"
示例#3
0
 def test_script_attrs(self, test_plot):
     js, tag = bes.autoload_static(test_plot, CDN, "some/path")
     html = bs4.BeautifulSoup(tag, "lxml")
     scripts = html.findAll(name='script')
     assert len(scripts) == 1
     attrs = scripts[0].attrs
     assert set(attrs) == set(['src', 'id'])
     assert attrs['src'] == 'some/path'
示例#4
0
 def test_script_attrs(self, test_plot):
     js, tag = bes.autoload_static(test_plot, CDN, "some/path")
     html = bs4.BeautifulSoup(tag, "lxml")
     scripts = html.findAll(name='script')
     assert len(scripts) == 1
     attrs = scripts[0].attrs
     assert set(attrs) == set(['src', 'id'])
     assert attrs['src'] == 'some/path'
示例#5
0
 def test_script_attrs(self, test_plot) -> None:
     js, tag = bes.autoload_static(test_plot, CDN, "some/path")
     html = bs4.BeautifulSoup(tag, "html.parser")
     scripts = html.findAll(name='script')
     assert "bokeh-widgets" not in js
     assert len(scripts) == 1
     attrs = scripts[0].attrs
     assert set(attrs) == set(['src', 'id'])
     assert attrs['src'] == 'some/path'
 def test_script_attrs(self, mock_make_id, test_plot):
     js, tag = bes.autoload_static(test_plot, CDN, "some/path")
     html = bs4.BeautifulSoup(tag, "lxml")
     scripts = html.findAll(name='script')
     assert len(scripts) == 1
     attrs = scripts[0].attrs
     assert set(attrs) == set(
         ['src', 'data-bokeh-model-id', 'id', 'data-bokeh-doc-id'])
     assert attrs['data-bokeh-doc-id'] == 'ID'
     assert attrs['data-bokeh-model-id'] == str(test_plot._id)
     assert attrs['src'] == 'some/path'
示例#7
0
 def test_script_attrs(self, mock_make_id, test_plot):
     js, tag = bes.autoload_static(test_plot, CDN, "some/path")
     html = bs4.BeautifulSoup(tag, "lxml")
     scripts = html.findAll(name='script')
     assert len(scripts) == 1
     attrs = scripts[0].attrs
     assert set(attrs) == set([
         'src',
         'data-bokeh-model-id',
         'id',
         'data-bokeh-doc-id'])
     assert attrs['data-bokeh-doc-id'] == 'ID'
     assert attrs['data-bokeh-model-id'] == str(test_plot._id)
     assert attrs['src'] == 'some/path'
示例#8
0
    def test_js_dev_cdn(self, version, monkeypatch, driver, test_file_path_and_url, test_plot) -> None:
        monkeypatch.setattr(buv, "__version__", "1.4.0rc1")
        monkeypatch.setattr(resources, "__version__", "1.4.0rc1")
        js, tag = bes.autoload_static(test_plot, CDN, "some/path")

        page = PAGE.render(js=js, tag=tag)

        path, url = test_file_path_and_url
        with open(path, "w") as f:
            f.write(page)

        driver.get(url)

        scripts = driver.find_elements_by_css_selector('head script')
        assert len(scripts) == 4
        for script in scripts:
            assert script.get_attribute("crossorigin") == None
            assert script.get_attribute("integrity") == ""
示例#9
0
    def test_js_release_dev_cdn(self, monkeypatch, driver, test_file_path_and_url, test_plot) -> None:
        monkeypatch.setattr(buv, "__version__", "2.0.0-foo")
        monkeypatch.setattr(resources, "__version__", "2.0.0-foo")
        js, tag = bes.autoload_static(test_plot, CDN, "some/path")

        page = PAGE.render(js=js, tag=tag)

        path, url = test_file_path_and_url
        with open(path, "w") as f:
            f.write(page)

        driver.get(url)

        scripts = driver.find_elements_by_css_selector('head script')
        for x in scripts:
            print(x.get_attribute("src"))
        assert len(scripts) == 4
        for script in scripts:
            assert script.get_attribute("crossorigin") == "anonymous"
            assert script.get_attribute("integrity").startswith("sha384-")
示例#10
0
    def test_js_dev_cdn(self, version: str, monkeypatch: pytest.MonkeyPatch,
                        driver: WebDriver, test_file_path_and_url: Tuple[str,
                                                                         str],
                        test_plot: figure) -> None:
        monkeypatch.setattr(buv, "__version__", "1.4.0rc1")
        monkeypatch.setattr(resources, "__version__", "1.4.0rc1")
        js, tag = bes.autoload_static(test_plot, CDN, "some/path")

        page = PAGE.render(js=js, tag=tag)

        path, url = test_file_path_and_url
        with open(path, "w") as f:
            f.write(page)

        driver.get(url)

        scripts = driver.find_elements(By.CSS_SELECTOR, 'head script')
        assert len(scripts) == 5
        for script in scripts:
            assert script.get_attribute("crossorigin") == None
            assert script.get_attribute("integrity") == ""
示例#11
0
    def test_js_release_server(self, monkeypatch: pytest.MonkeyPatch,
                               driver: WebDriver,
                               test_file_path_and_url: Tuple[str, str],
                               test_plot: Figure) -> None:
        monkeypatch.setattr(buv, "__version__", "2.0.0")
        monkeypatch.setattr(resources, "__version__", "2.0.0")
        js, tag = bes.autoload_static(test_plot,
                                      resources.Resources(mode="server"),
                                      "some/path")

        page = PAGE.render(js=js, tag=tag)

        path, url = test_file_path_and_url
        with open(path, "w") as f:
            f.write(page)

        driver.get(url)

        scripts = driver.find_elements_by_css_selector('head script')
        assert len(scripts) == 5
        for script in scripts:
            assert script.get_attribute("crossorigin") == None
            assert script.get_attribute("integrity") == ""
示例#12
0
 def test_return_type(self, test_plot: figure) -> None:
     r = bes.autoload_static(test_plot, CDN, "some/path")
     assert len(r) == 2
示例#13
0
 def test_return_type(self, test_plot):
     r = bes.autoload_static(test_plot, CDN, "some/path")
     assert len(r) == 2