コード例 #1
0
ファイル: test_saving.py プロジェクト: nimishbongale/bokeh
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
コード例 #2
0
ファイル: test_saving.py プロジェクト: nimishbongale/bokeh
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"
コード例 #3
0
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"
コード例 #4
0
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"
コード例 #5
0
ファイル: test_saving.py プロジェクト: nimishbongale/bokeh
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"
コード例 #6
0
ファイル: test_saving.py プロジェクト: zebulon2/bokeh
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
コード例 #7
0
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] == {}
コード例 #8
0
ファイル: test_saving.py プロジェクト: jsalcal/bokeh
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] == {}
コード例 #9
0
ファイル: test_saving.py プロジェクト: nimishbongale/bokeh
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] == {}
コード例 #10
0
ファイル: test_saving.py プロジェクト: nimishbongale/bokeh
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
コード例 #11
0
ファイル: test_saving.py プロジェクト: jsalcal/bokeh
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] == {}
コード例 #12
0
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] == {}
コード例 #13
0
ファイル: test_saving.py プロジェクト: digitalsatori/Bokeh
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")
コード例 #14
0
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"}
コード例 #15
0
ファイル: test_saving.py プロジェクト: jsalcal/bokeh
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"}
コード例 #16
0
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")
コード例 #17
0
ファイル: test_saving.py プロジェクト: nimishbongale/bokeh
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")
コード例 #18
0
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"
コード例 #19
0
ファイル: test_saving.py プロジェクト: jsalcal/bokeh
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"
コード例 #20
0
def test__get_save_args_explicit_resources():
    filename, resources, title = bis._get_save_args(curstate(), "filename",
                                                    "resources", "title")
    assert resources == "resources"
コード例 #21
0
ファイル: test_saving.py プロジェクト: nimishbongale/bokeh
def test__get_save_args_explicit_title() -> None:
    _, _, title = bis._get_save_args(curstate(), "filename", "inline", "title")
    assert title == "title"
コード例 #22
0
def test__get_save_args_explicit_title() -> None:
    filename, resources, title = bis._get_save_args(curstate(), "filename",
                                                    "resources", "title")
    assert title == "title"
コード例 #23
0
ファイル: test_saving.py プロジェクト: jsalcal/bokeh
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"
コード例 #24
0
ファイル: test_saving.py プロジェクト: jsalcal/bokeh
def test__get_save_args_explicit_resources():
    filename, resources, title = bis._get_save_args(curstate(), "filename", "resources", "title")
    assert resources == "resources"
コード例 #25
0
ファイル: test_saving.py プロジェクト: jsalcal/bokeh
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"
コード例 #26
0
ファイル: test_saving.py プロジェクト: nimishbongale/bokeh
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"