def test_FileManager_get_fail(): """ The on_get_fail signal is emitted when a problem is encountered. """ fm = FileManager("/dev/ttyUSB0") fm.on_get_fail = mock.MagicMock() with mock.patch('mu.modes.base.microfs.get', side_effect=Exception('boom')): fm.get('foo.py', 'bar.py') fm.on_get_fail.emit.assert_called_once_with('foo.py')
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("/dev/ttyUSB0") fm.serial = mock.MagicMock() fm.on_get_file = mock.MagicMock() mock_get = mock.MagicMock() with mock.patch('mu.modes.base.microfs.get', mock_get): fm.get('foo.py', 'bar.py') mock_get.assert_called_once_with('foo.py', 'bar.py', serial=fm.serial) fm.on_get_file.emit.assert_called_once_with('foo.py')