コード例 #1
0
ファイル: test_base.py プロジェクト: watrt/mu
def test_micropython_mode_remove_plotter_active_repl():
    """
    When removing the plotter, if the repl is active, retain the
    connection.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    mm = MicroPythonMode(editor, view)
    mm.connection = mock.MagicMock()
    mm.repl = True
    mm.remove_plotter()
    assert mm.plotter is False
    assert mm.connection is not None
コード例 #2
0
ファイル: test_base.py プロジェクト: watrt/mu
def test_micropython_mode_remove_plotter_disconnects():
    """
    Ensure that connections are closed when plotter is closed.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    mm = MicroPythonMode(editor, view)
    mm.repl = False
    mm.plotter = True
    mock_repl_connection = mock.MagicMock()
    mm.connection = mock_repl_connection
    mm.remove_plotter()
    mock_repl_connection.close.assert_called_once_with()
    assert mm.connection is None
コード例 #3
0
ファイル: test_base.py プロジェクト: watrt/mu
def test_micropython_mode_remove_repl_and_disconnect():
    """
    If there is a repl, make sure it's removed as expected and the state is
    updated. Disconnect any open serial connection.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    mm = MicroPythonMode(editor, view)
    mm.repl = True
    mm.plotter = False
    mock_repl_connection = mock.MagicMock()
    mm.connection = mock_repl_connection
    mm.remove_repl()
    mock_repl_connection.close.assert_called_once_with()
    assert mm.connection is None
コード例 #4
0
ファイル: test_base.py プロジェクト: watrt/mu
def test_micropython_device_changed(microbit):
    """
    Ensure REPL/Plotter and connection are reconnected, when the
    user changes device.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.show_device_selector = mock.MagicMock()
    view.hide_device_selector = mock.MagicMock()
    mm = MicroPythonMode(editor, view)
    mm.add_repl = mock.MagicMock()
    mm.add_plotter = mock.MagicMock()
    mm.remove_repl = mock.MagicMock()
    mm.remove_plotter = mock.MagicMock()
    mm.repl = True
    mm.plotter = True
    mm.connection = mock.MagicMock()
    mm.activate()
    mm.device_changed(microbit)
    mm.add_repl.assert_called_once_with()
    mm.add_plotter.assert_called_once_with()
    mm.remove_repl.assert_called_once_with()
    mm.remove_plotter.assert_called_once_with()
    mm.connection.send_interrupt.assert_called_once_with()