def test__get_save_args_explicit_resources() -> None: _, resources, _ = bis._get_save_args(curstate(), "filename", "inline", "title") assert resources.mode == "inline" # TODO: == Resources(mode="inline") _, resources, _ = bis._get_save_args(curstate(), "filename", INLINE, "title") assert resources == INLINE
def test__get_save_args_explicit_filename() -> None: filename, _, _ = bis._get_save_args(curstate(), "filename", "inline", "title") assert filename == "filename" filename, _, _ = bis._get_save_args(curstate(), Path("some") / "path" / "filename", "inline", "title") assert filename == Path("some") / "path" / "filename"
def test__get_save_args_default_resources() -> None: curstate().reset() curstate().output_file("filename") curstate().file['resources'] = "resources" filename, resources, title = bis._get_save_args(curstate(), "filename", None, "title") assert resources == "resources"
def test__get_save_args_default_title() -> None: curstate().reset() curstate().output_file("filename") curstate().file['title'] = "title" filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", None) assert title == "title"
def test__get_save_args_default_title() -> None: state = curstate() state.reset() state.output_file("filename", title="title") assert state.file is not None assert state.file.title == "title" _, _, title = bis._get_save_args(curstate(), "filename", "inline", None) assert title == "title"
def test__get_save_args_default_resources() -> None: state = curstate() state.reset() state.output_file("filename") assert state.file is not None state.file.resources = INLINE _, resources, _ = bis._get_save_args(curstate(), "filename", None, "title") assert resources == INLINE
def test__get_save_args_missing_title(mock_warn): curstate().reset() filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", None) assert title == "Bokeh Plot" assert mock_warn.call_count == 1 assert mock_warn.call_args[0] == ( "save() called but no title was supplied and output_file(...) was never called, using default title 'Bokeh Plot'", ) assert mock_warn.call_args[1] == {}
def test__get_save_args_missing_resources(mock_warn: MagicMock) -> None: curstate().reset() _, resources, _ = bis._get_save_args(curstate(), "filename", None, "title") assert resources.mode == "cdn" assert mock_warn.call_count == 1 assert mock_warn.call_args[0] == ( "save() called but no resources were supplied and output_file(...) was never called, defaulting to resources.CDN", ) assert mock_warn.call_args[1] == {}
def test__get_save_args_default_resources() -> None: state = curstate() state.reset() state.output_file("filename", mode="inline") assert state.file is not None assert state.file.resources.mode == "inline" r = state.file.resources _, resources, _ = bis._get_save_args(curstate(), "filename", None, "title") assert resources == r
def test__get_save_args_missing_resources(mock_warn): from bokeh.resources import CDN curstate().reset() filename, resources, title = bis._get_save_args(curstate(), "filename", None, "title") assert resources == CDN assert mock_warn.call_count == 1 assert mock_warn.call_args[0] == ( "save() called but no resources were supplied and output_file(...) was never called, defaulting to resources.CDN", ) assert mock_warn.call_args[1] == {}
def test__save_helper(mock_file_html, mock_io_open): obj = Plot() filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", "title") bis._save_helper(obj, filename, resources, title, None) assert mock_file_html.call_count == 1 assert mock_file_html.call_args[0] == (obj, resources) assert mock_file_html.call_args[1] == dict(title="title", template=None) assert mock_io_open.call_count == 1 assert mock_io_open.call_args[0] == (filename,) assert mock_io_open.call_args[1] == dict(mode="w", encoding="utf-8")
def test__save_helper(mock_file_html, mock_io_open): obj = Plot() filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", "title") bis._save_helper(obj, filename, resources, title) assert mock_file_html.call_count == 1 assert mock_file_html.call_args[0] == (obj, resources) assert mock_file_html.call_args[1] == {"title": "title"} assert mock_io_open.call_count == 1 assert mock_io_open.call_args[0] == (filename,) assert mock_io_open.call_args[1] == {"mode":"w", "encoding":"utf-8"}
def test__save_helper(mock_file_html, mock_io_open): obj = Plot() filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", "title") bis._save_helper(obj, filename, resources, title, None) assert mock_file_html.call_count == 1 assert mock_file_html.call_args[0] == (obj, resources) assert mock_file_html.call_args[1] == dict(title="title", template=None) assert mock_io_open.call_count == 1 assert mock_io_open.call_args[0] == (filename, ) assert mock_io_open.call_args[1] == dict(mode="w", encoding="utf-8")
def test__save_helper(mock_file_html: MagicMock, mock_open: MagicMock) -> None: obj = Plot() filename, resources, title = bis._get_save_args(curstate(), "filename", "inline", "title") bis._save_helper(obj, filename, resources, title, None) assert mock_file_html.call_count == 1 assert mock_file_html.call_args[0] == (obj, resources) assert mock_file_html.call_args[1] == dict(title="title", template=FILE, theme=None) assert mock_open.call_count == 1 assert mock_open.call_args[0] == (filename, ) assert mock_open.call_args[1] == dict(mode="w", encoding="utf-8")
def test__get_save_args_default_filename() -> None: curstate().reset() curstate().output_file("filename") filename, resources, title = bis._get_save_args(curstate(), None, "resources", "title") assert filename == "filename"
def test__get_save_args_default_filename(): curstate().reset() curstate().output_file("filename") filename, resources, title = bis._get_save_args(curstate(), None, "resources", "title") assert filename == "filename"
def test__get_save_args_explicit_resources(): filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", "title") assert resources == "resources"
def test__get_save_args_explicit_title() -> None: _, _, title = bis._get_save_args(curstate(), "filename", "inline", "title") assert title == "title"
def test__get_save_args_explicit_title() -> None: filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", "title") assert title == "title"
def test__get_save_args_default_resources(): curstate().reset() curstate().output_file("filename") curstate().file['resources'] = "resources" filename, resources, title = bis._get_save_args(curstate(), "filename", None, "title") assert resources == "resources"
def test__get_save_args_default_title(): curstate().reset() curstate().output_file("filename") curstate().file['title'] = "title" filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", None) assert title == "title"
def test__get_save_args_default_filename() -> None: curstate().reset() curstate().output_file("filename") filename, _, _ = bis._get_save_args(curstate(), None, "inline", "title") assert filename == "filename"