コード例 #1
0
def test_FileManager_ls_fail():
    """
    The on_list_fail signal is emitted when a problem is encountered.
    """
    fm = FileManager("/dev/ttyUSB0")
    fm.on_list_fail = mock.MagicMock()
    with mock.patch('mu.modes.base.microfs.ls', side_effect=Exception('boom')):
        fm.ls()
    fm.on_list_fail.emit.assert_called_once_with()
コード例 #2
0
def test_FileManager_on_start_fails():
    """
    When a thread signals it has started, but the serial connection cannot be
    established, ensure that the on_list_fail is emitted to signal Mu can't get
    the list of files from the board (because a connection cannot be
    established).
    """
    fm = FileManager("/dev/ttyUSB0")
    fm.on_list_fail = mock.MagicMock()
    mock_serial = mock.MagicMock(side_effect=Exception('BOOM!'))
    with mock.patch('mu.modes.base.Serial', mock_serial):
        fm.on_start()
        mock_serial.assert_called_once_with("/dev/ttyUSB0",
                                            115200,
                                            timeout=1,
                                            parity='N')
    fm.on_list_fail.emit.assert_called_once_with()