Пример #1
0
def test_output_svg_bokeh_err(mocker):
    mocker.patch('solarforecastarbiter.reports.figures.bokeh_figures.get_svgs',
                 side_effect=RuntimeError)
    logger = mocker.patch(
        'solarforecastarbiter.reports.figures.bokeh_figures.logger')
    from bokeh.plotting import figure
    fig = figure(title='line', name='line_plot')
    fig.line([0, 1], [0, 1])
    with figures._make_webdriver() as driver:
        svg = figures.output_svg(fig, driver)
    assert svg.startswith('<svg')
    assert svg.endswith('</svg>')
    assert logger.error.called
Пример #2
0
def test_output_svg_no_phantom(mocker):
    pytest.importorskip('selenium')
    mocker.patch('selenium.webdriver.PhantomJS', side_effect=RuntimeError)
    logger = mocker.patch(
        'solarforecastarbiter.reports.figures.bokeh_figures.logger')
    from bokeh.plotting import figure
    fig = figure(title='line', name='line_plot')
    fig.line([0, 1], [0, 1])
    with figures._make_webdriver() as driver:
        svg = figures.output_svg(fig, driver)
    assert svg.startswith('<svg')
    assert 'Unable' in svg
    assert svg.endswith('</svg>')
    assert logger.error.called
Пример #3
0
def test_output_svg(mocker, no_stray_phantomjs):
    pytest.importorskip('selenium')
    if shutil.which('phantomjs') is None:  # pragma: no cover
        pytest.skip('PhantomJS must be on PATH to make SVGs')
    logger = mocker.patch(
        'solarforecastarbiter.reports.figures.bokeh_figures.logger')
    from bokeh.plotting import figure
    fig = figure(title='line', name='line_plot')
    fig.line([0, 1], [0, 1])
    with figures._make_webdriver() as driver:
        svg = figures.output_svg(fig, driver=driver)
    assert svg.startswith('<svg')
    assert svg.endswith('</svg>')
    assert not logger.error.called