Exemplo n.º 1
0
def test_FileManager_get_fail():
    """
    The on_get_fail signal is emitted when a problem is encountered.
    """
    fm = FileManager()
    fm.on_get_fail = mock.MagicMock()
    with mock.patch('mu.modes.microbit.microfs.get',
                    side_effect=Exception('boom')):
        fm.get('foo.py', 'bar.py')
    fm.on_get_fail.emit.assert_called_once_with('foo.py')
Exemplo n.º 2
0
def test_FileManager_get_fail():
    """
    The on_get_fail signal is emitted when a problem is encountered.
    """
    fm = FileManager()
    fm.on_get_fail = mock.MagicMock()
    with mock.patch('mu.modes.microbit.microfs.get_serial',
                    side_effect=Exception('boom')):
        fm.get('foo.py', 'bar.py')
    fm.on_get_fail.emit.assert_called_once_with('foo.py')
Exemplo n.º 3
0
def test_fileManager_get():
    """
    The on_get_file signal is emitted with the name of the effected file when
    microfs.get completes successfully.
    """
    fm = FileManager()
    fm.on_get_file = mock.MagicMock()
    mock_get = mock.MagicMock()
    with mock.patch('mu.modes.microbit.microfs.get', mock_get):
        fm.get('foo.py', 'bar.py')
    mock_get.assert_called_once_with('foo.py', 'bar.py')
    fm.on_get_file.emit.assert_called_once_with('foo.py')
Exemplo n.º 4
0
def test_fileManager_get():
    """
    The on_get_file signal is emitted with the name of the effected file when
    microfs.get completes successfully.
    """
    fm = FileManager()
    fm.on_get_file = mock.MagicMock()
    mock_get = mock.MagicMock()
    mock_serial = mock.MagicMock()
    with mock.patch('mu.modes.microbit.microfs.get', mock_get),\
            mock.patch('mu.modes.microbit.microfs.get_serial', mock_serial):
        fm.get('foo.py', 'bar.py')
    mock_get.assert_called_once_with('foo.py', 'bar.py',
                                     mock_serial().__enter__())
    fm.on_get_file.emit.assert_called_once_with('foo.py')