def test__get_svgs_no_svg_present(): layout = Plot(x_range=Range1d(), y_range=Range1d(), plot_height=20, plot_width=20, toolbar_location=None) svgs = io._get_svgs(layout, None) assert svgs == []
def test__get_svgs_with_svg_present(): layout = Plot(x_range=Range1d(), y_range=Range1d(), plot_height=20, plot_width=20, toolbar_location=None, outline_line_color=None, border_fill_color=None, background_fill_color=None, output_backend="svg") svgs = io._get_svgs(layout) assert svgs[0] == ('<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' 'width="20" height="20" style="width: 20px; height: 20px;"><defs/><g><g/><g transform="scale(1,1) ' 'translate(0.5,0.5)"><rect fill="#FFFFFF" stroke="none" x="0" y="0" width="20" height="20"/><g/><g/><g/><g/></g></g></svg>')
def file_contents(self, args, doc): if args.width is not None or args.height is not None: layout = doc.roots if len(layout) != 1 or not isinstance(layout[0], Plot): warnings.warn( "Export called with height or width kwargs on a non-single Plot layout. The size values will be ignored." ) else: plot = layout[0] plot.plot_height = args.height or plot.plot_height plot.plot_width = args.width or plot.plot_width return _get_svgs(doc, driver=self.driver)
def file_contents(self, args, doc): ''' ''' if args.width is not None or args.height is not None: layout = doc.roots if len(layout) != 1 or not isinstance(layout[0], Plot): warnings.warn("Export called with height or width kwargs on a non-single Plot layout. The size values will be ignored.") else: plot = layout[0] plot.plot_height = args.height or plot.plot_height plot.plot_width = args.width or plot.plot_width return _get_svgs(doc, driver=self.driver)
def test__get_svgs_with_svg_present_with_driver(): layout = Plot(x_range=Range1d(), y_range=Range1d(), plot_height=20, plot_width=20, toolbar_location=None, outline_line_color=None, border_fill_color=None, background_fill_color=None, output_backend="svg") driver = webdriver.PhantomJS(service_log_path=os.path.devnull) svgs = io._get_svgs(layout) # Have to manually clean up the driver session driver.quit() assert svgs[0] == ('<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' 'width="20" height="20" style="width: 20px; height: 20px;"><defs/><g><g/><g transform="scale(1,1) ' 'translate(0.5,0.5)"><rect fill="#FFFFFF" stroke="none" x="0" y="0" width="20" height="20"/><g/><g/><g/><g/></g></g></svg>')
def test__get_svgs_no_svg_present(): layout = Plot(x_range=Range1d(), y_range=Range1d(), plot_height=20, plot_width=20, toolbar_location=None) svgs = io._get_svgs(layout) assert svgs == []
def file_contents(self, args, doc): return _get_svgs(doc, self.driver)