def test_js_dump(self): self.json_content[self.key] = self.value web = Webviz('title', theme='minimal') page = Page('pagetitle') page.add_content(self.json_content) web.add(page) tempdir = tempfile.mkdtemp() web.write_html(tempdir, overwrite=True, display=False)
def test_js_dump(self): self.json_content[self.key] = self.value web = Webviz('title', theme='minimal') page = Page('pagetitle') page.add_content(self.json_content) web.add(page) tempdir = tempfile.mkdtemp() web.write_html(tempdir, overwrite=True, display=False) js_deps = self.json_content.get_js_dep() path.isfile(path.join(tempdir, 'resources', 'js', js_deps[0].name))
def test_special_character_title(self): web = Webviz("øæåõ", theme='minimal') web.add(Page("øæå~")) web.add(Page("øæå~ÆÆÆAAAÅÅÅ")) folder = tempfile.mkdtemp() web.write_html(folder, overwrite=True, display=False) shutil.rmtree(folder)
To prevent build failing because of backslashes, use a rawstring format by adding `r` in front of the string. You can read more about the input format [here](http://docs.mathjax.org/en/latest/tex.html#). Example: `formula = Markdown(r'$$x_{1,2} = \frac{-b \pm \sqrt{b^2-4ac}}{2b}.$$')` Renders out to this: $$x_{1,2} = \frac{-b \pm \sqrt{b^2-4ac}}{2b}.$$ """) ex3.add_content(Markdown(some_content)) submenu1 = SubMenu('Menu 1') submenu2 = SubMenu('Menu 2') submenu3 = SubMenu('Menu 3') submenu1.add_page(ex1) submenu2.add_page(ex2) submenu3.add_page(ex3) web.add(submenu1) web.add(submenu2) web.add(submenu3) web.write_html("./webviz_example", overwrite=True, display=False)
from webviz import Webviz, Page, SubMenu web = Webviz('Main title', theme='default') ex1 = Page('Example 1') ex2 = Page('Example 2') submenu1 = SubMenu('Menu 1') submenu2 = SubMenu('Menu 2') submenu1.add_page(ex1) submenu2.add_page(ex2) web.add(submenu1) web.add(submenu2) page3 = Page('Example 3') web.add(page3) web.write_html("./webviz_tutorial", overwrite=True, display=False)
class TestWebviz(unittest.TestCase): def setUp(self): self.page = Page('test page') self.submenu = SubMenu('test page') self.webviz = Webviz('test portal', theme='minimal') def test_non_theme(self): with self.assertRaises(ValueError): Webviz(title='bomb', theme=3.14) @patch('webviz._webviz.webbrowser') def test_display(self, webbrowser_mock): folder = tempfile.mkdtemp() self.webviz.write_html(folder, True, True) shutil.rmtree(folder) webbrowser_mock.open_new_tab.assert_called_once() def test_add_non_page(self): with self.assertRaises(ValueError): self.webviz.add('not a page or SubMenu') def test_add_page(self): self.webviz.add(self.page) self.assertIn(self.page, self.webviz.menu) def test_add_submenu(self): self.submenu.add_page(self.page) self.webviz.add(self.submenu) self.assertIn(self.submenu, self.webviz.menu) self.assertIn(self.page, self.webviz.pages) def test_render(self): self.submenu.add_page(self.page) self.webviz.add(self.submenu) folder = tempfile.mkdtemp() self.webviz.write_html(folder, overwrite=True) shutil.rmtree(folder) def test_overwrite(self): self.submenu.add_page(self.page) self.webviz.add(self.submenu) folder = tempfile.mkdtemp() self.webviz.write_html(folder, overwrite=True) with self.assertRaises(ValueError): self.webviz.write_html(folder, overwrite=False) self.webviz.write_html(folder, overwrite=True) shutil.rmtree(folder) def test_write_banner(self): self.submenu.add_page(self.page) (_, testbanner) = tempfile.mkstemp(suffix='.jpg') self.webviz = Webviz('test portal', banner_image=testbanner, theme='minimal') self.webviz.add(self.submenu) folder = tempfile.mkdtemp() self.webviz.write_html(folder, overwrite=True) absolute_banner_filename = os.path.join(folder, self.webviz.banner_filename) self.assertTrue(os.path.isfile(absolute_banner_filename)) shutil.rmtree(folder)
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Example of adding tornado plots to webviz project before running, currently using: source /project/res/komodo/testing/enable for webviz """ from __future__ import division, print_function, absolute_import from fmu.tools.sensitivities import add_webviz_tornadoplots from webviz import Webviz html_foldername = "./webviz_example" title = "Snorreberg" web = Webviz(title, theme="equinor") configpath = "../tests/data/sensitivities/config/" # add different types of plots to webportal add_webviz_tornadoplots(web, configpath + "config_example_geovolume_ensemble.yaml") add_webviz_tornadoplots(web, configpath + "config_example_geovolume.yaml") add_webviz_tornadoplots(web, configpath + "config_example_eclipse.yaml") # Finally, write html web.write_html(html_foldername, overwrite=True, display=True)