def test_python_add_plotter(): """ Ensure the plotter is added as expected. """ editor = mock.MagicMock() view = mock.MagicMock() pm = PythonMode(editor, view) pm.set_buttons = mock.MagicMock() pm.add_plotter() view.add_python3_plotter.assert_called_once_with(pm) assert pm.plotter pm.set_buttons.assert_called_once_with(debug=False) # Check button states are updated depending on other aspects of the mode # being enabled. # REPL active. pm.set_buttons.reset_mock() pm.repl = True pm.add_plotter() assert pm.set_buttons.call_count == 2 assert pm.set_buttons.call_args_list[0][1]["debug"] is False assert pm.set_buttons.call_args_list[1][1]["run"] is False # Runner active. pm.set_buttons.reset_mock() pm.repl = False pm.runner = True pm.add_plotter() assert pm.set_buttons.call_count == 2 assert pm.set_buttons.call_args_list[0][1]["debug"] is False assert pm.set_buttons.call_args_list[1][1]["repl"] is False
def test_python_add_plotter(): """ Ensure the plotter is added as expected. """ editor = mock.MagicMock() view = mock.MagicMock() pm = PythonMode(editor, view) pm.set_buttons = mock.MagicMock() pm.add_plotter() view.add_python3_plotter.assert_called_once_with(pm) assert pm.plotter pm.set_buttons.assert_called_once_with(debug=False) # Check button states are updated depending on other aspects of the mode # being enabled. # REPL active. pm.set_buttons.reset_mock() pm.repl = True pm.add_plotter() assert pm.set_buttons.call_count == 2 assert pm.set_buttons.call_args_list[0][1]['debug'] is False assert pm.set_buttons.call_args_list[1][1]['run'] is False # Runner active. pm.set_buttons.reset_mock() pm.repl = False pm.runner = True pm.add_plotter() assert pm.set_buttons.call_count == 2 assert pm.set_buttons.call_args_list[0][1]['debug'] is False assert pm.set_buttons.call_args_list[1][1]['repl'] is False
def test_python_toggle_plotter(): """ Ensure toggling the plotter causes it to be added/removed. """ editor = mock.MagicMock() view = mock.MagicMock() pm = PythonMode(editor, view) pm.add_plotter = mock.MagicMock() pm.remove_plotter = mock.MagicMock() pm.toggle_plotter() pm.add_plotter.assert_called_once_with() pm.plotter = True pm.toggle_plotter() pm.remove_plotter.assert_called_once_with()