def test__show_with_state_with_notebook(mock_get_browser_controller, mock__show_file_with_state, mock_run_notebook_hook): mock_get_browser_controller.return_value = "controller" s = State() p = Plot() s.output_notebook() bis._show_with_state(p, s, "browser", "new") assert s.notebook_type == "jupyter" assert mock_run_notebook_hook.call_count == 1 assert mock_run_notebook_hook.call_args[0] == ("jupyter", "doc", p, s, False) assert mock_run_notebook_hook.call_args[1] == {} assert mock__show_file_with_state.call_count == 0 s.output_file("foo.html") bis._show_with_state(p, s, "browser", "new") assert s.notebook_type == "jupyter" assert mock_run_notebook_hook.call_count == 2 assert mock_run_notebook_hook.call_args[0] == ("jupyter", "doc", p, s, False) assert mock_run_notebook_hook.call_args[1] == {} assert mock__show_file_with_state.call_count == 1 assert mock__show_file_with_state.call_args[0] == (p, s, "new", "controller") assert mock__show_file_with_state.call_args[1] == {}
def test__show_with_state_with_notebook(mock_get_browser_controller, mock__show_file_with_state, mock_run_notebook_hook): mock_get_browser_controller.return_value = "controller" s = State() p = Plot() s.output_notebook() bis._show_with_state(p, s, "browser", "new") assert s.notebook_type == "jupyter" assert mock_run_notebook_hook.call_count == 1 assert mock_run_notebook_hook.call_args[0] == ("jupyter", "doc", p, s, False) assert mock_run_notebook_hook.call_args[1] == {} assert mock__show_file_with_state.call_count == 0 s.output_file("foo.html") bis._show_with_state(p, s, "browser", "new") assert s.notebook_type == "jupyter" assert mock_run_notebook_hook.call_count == 2 assert mock_run_notebook_hook.call_args[0] == ("jupyter", "doc", p, s, False) assert mock_run_notebook_hook.call_args[1] == {} assert mock__show_file_with_state.call_count == 1 assert mock__show_file_with_state.call_args[0] == (p, s, "new", "controller") assert mock__show_file_with_state.call_args[1] == {}
def test__show_with_state_with_no_notebook(mock_get_browser_controller, mock__show_file_with_state, mock_show_doc, mock_get_comms): mock_get_browser_controller.return_value = "controller" mock_get_comms.return_value = "comms" s = State() s.output_file("foo.html") bis._show_with_state("obj", s, "browser", "new") assert s.notebook_type == None assert mock_show_doc.call_count == 0 assert mock__show_file_with_state.call_count == 1 assert mock__show_file_with_state.call_args[0] == ("obj", s, "new", "controller") assert mock__show_file_with_state.call_args[1] == {}
def test__show_with_state_with_no_notebook(mock_get_browser_controller, mock__show_file_with_state, mock_show_doc, mock_get_comms): mock_get_browser_controller.return_value = "controller" mock_get_comms.return_value = "comms" s = State() s.output_file("foo.html") bis._show_with_state("obj", s, "browser", "new") assert s.notebook_type == None assert mock_show_doc.call_count == 0 assert mock__show_file_with_state.call_count == 1 assert mock__show_file_with_state.call_args[0] == ("obj", s, "new", "controller") assert mock__show_file_with_state.call_args[1] == {}