Exemplo n.º 1
0
def test_get_svg_with_svg_present(webdriver: WebDriver) -> None:
    plot = lambda color: Plot(
        x_range=Range1d(),
        y_range=Range1d(),
        height=20,
        width=20,
        toolbar_location=None,
        outline_line_color=None,
        border_fill_color=None,
        background_fill_color=color,
        output_backend="svg",
    )

    layout = row([plot("red"), plot("blue")])

    with silenced(MISSING_RENDERERS):
        svgs0 = bie.get_svg(layout, driver=webdriver)
        svgs1 = bie.get_svg(layout, driver=webdriver)

    svgs2 = [
        '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="40" height="20">'
        '<defs/>'
        '<path fill="rgb(255,0,0)" stroke="none" paint-order="stroke" d="M 5.5 5.5 L 15.5 5.5 L 15.5 15.5 L 5.5 15.5 L 5.5 5.5" fill-opacity="1"/>'
        '<g transform="matrix(1, 0, 0, 1, 20, 0)">'
        '<path fill="rgb(0,0,255)" stroke="none" paint-order="stroke" d="M 5.5 5.5 L 15.5 5.5 L 15.5 15.5 L 5.5 15.5 L 5.5 5.5" fill-opacity="1"/>'
        '</g>'
        '</svg>',
    ]

    assert svgs0 == svgs2
    assert svgs1 == svgs2
Exemplo n.º 2
0
def test_get_svg_no_svg_present() -> None:
    layout = Plot(x_range=Range1d(), y_range=Range1d(), plot_height=20, plot_width=20, toolbar_location=None)

    with silenced(MISSING_RENDERERS):
        svgs = bie.get_svg(layout)

    assert svgs == [
        '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20">'
            '<defs/>'
            '<image width="20" height="20" preserveAspectRatio="none" xlink:href="'
            'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAbElEQVQ4T2P8//+/AwMDAwhTBTD+//+/gYGBoZ4'
            'qpjEwMIwaCAnJN2/eMPz69YtgsLKxsTGIiIigqMMahs+ePWOQkpIiaCA2daMGQoJtNAxxJp+BSzbE5hRmZuYL4uLiBsheGC1tCJYHBBUAAA7h'
            'kkaBfwzpAAAAAElFTkSuQmCC"/>'
        '</svg>',
    ]
Exemplo n.º 3
0
def test_get_svg_no_svg_present(webdriver: WebDriver) -> None:
    layout = Plot(
        x_range=Range1d(),
        y_range=Range1d(),
        height=20,
        width=20,
        toolbar_location=None,
        outline_line_color=None,
        border_fill_color=None,
        background_fill_color="red",
        output_backend="canvas",
    )

    with silenced(MISSING_RENDERERS):
        svgs = bie.get_svg(layout, driver=webdriver)

    def output(data: str) -> List[str]:
        return [
            '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20">'
            '<defs/>'
            f'<image width="20" height="20" preserveAspectRatio="none" href="data:image/png;base64,{data}"/>'
            '</svg>'
        ]

    chrome_data = (
        "iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAFNJ"
        "REFUOE9jZKAyYKSyeQyjBkJC9D8DgwMDBBMCBxgZGA4gK8Iahv8ZGBoYGBjqCZnGwMDQ"
        "yAhRCwejBsIjZTQMcSaggUs21M0pROQQnEpGYPEFALJrIRXAq4rZAAAAAElFTkSuQmCC")
    firefox_data = (
        "iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAUUlEQVQ4T2NkoDJgpLJ5D"
        "KMGQkL0PwODA5ACYULgADDMDiArwhqGQAMbgIrqCZkGlG8EGgBSCwejBsIjZTQMcSaggUs"
        "21M0pROQQnEpGYPEFALJrIRV3ULevAAAAAElFTkSuQmCC")

    if webdriver.name == "chrome":
        assert svgs == output(chrome_data)
    else:
        assert svgs == output(firefox_data)
Exemplo n.º 4
0
def test_get_svg_no_svg_present(webdriver: WebDriver) -> None:
    layout = Plot(
        x_range=Range1d(),
        y_range=Range1d(),
        height=20,
        width=20,
        toolbar_location=None,
        outline_line_color=None,
        border_fill_color=None,
        background_fill_color="red",
        output_backend="canvas",
    )

    with silenced(MISSING_RENDERERS):
        svgs = bie.get_svg(layout, driver=webdriver)

    def output(data: str) -> List[str]:
        return [
            '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20">'
            '<defs/>'
            f'<image width="20" height="20" preserveAspectRatio="none" href="data:image/png;base64,{data}"/>'
            '</svg>'
        ]

    chrome_data = (
        "iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAFNJ"
        "REFUOE9jZKAyYKSyeQyjBkJC9D8DgwMDBBMCBxgZGA4gK8Iahv8ZGBoYGBjqCZnGwMDQ"
        "yAhRCwejBsIjZTQMcSaggUs21M0pROQQnEpGYPEFALJrIRXAq4rZAAAAAElFTkSuQmCC")
    firefox_data = (
        "iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAMUlEQVQ4jWNgGAVDA/xnY"
        "HD4z8DQQAR2INbAhv8MDP+JwA2jBo4aOJQMpG5OGQUkAQCAKdw3str/WgAAAABJRU5ErkJggg=="
    )

    name = webdriver.name
    assert name == "chrome" and svgs == output(
        chrome_data) or name == "firefox" and svgs == output(firefox_data)