示例#1
0
def test_run_toggle_off():
    """
    Check the handler for toggling the local server stops the process and
    reverts the UI state.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    wm = WebMode(editor, view)
    wm.runner = True
    wm.stop_server = mock.MagicMock()
    wm.set_buttons = mock.MagicMock()
    wm.run_toggle(None)
    wm.stop_server.assert_called_once_with()
    slot = wm.view.button_bar.slots["play"]
    assert slot.setIcon.call_count == 1
    slot.setText.assert_called_once_with("Run")
    slot.setToolTip.assert_called_once_with("Run the web server.")
    wm.set_buttons.assert_called_once_with(modes=True)
示例#2
0
def test_run_toggle_on():
    """
    Check the handler for running the local server starts the sub-process and
    updates the UI state.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    wm = WebMode(editor, view)
    wm.runner = None

    def runner(wm=wm):
        wm.runner = True

    wm.start_server = mock.MagicMock(side_effect=runner)
    wm.set_buttons = mock.MagicMock()
    wm.run_toggle(None)
    wm.start_server.assert_called_once_with()
    slot = wm.view.button_bar.slots["run"]
    assert slot.setIcon.call_count == 1
    slot.setText.assert_called_once_with("Stop")
    slot.setToolTip.assert_called_once_with("Stop the web server.")
    wm.set_buttons.assert_called_once_with(modes=False)