def test_FileManager_put_fail(): """ The on_put_fail signal is emitted when a problem is encountered. """ fm = FileManager("/dev/ttyUSB0") fm.on_put_fail = mock.MagicMock() with mock.patch('mu.modes.base.microfs.put', side_effect=Exception('boom')): fm.put('foo.py') fm.on_put_fail.emit.assert_called_once_with('foo.py')
def test_FileManager_put(): """ The on_put_file signal is emitted with the name of the effected file when microfs.put completes successfully. """ fm = FileManager("/dev/ttyUSB0") fm.serial = mock.MagicMock() fm.on_put_file = mock.MagicMock() mock_put = mock.MagicMock() path = os.path.join('directory', 'foo.py') with mock.patch('mu.modes.base.microfs.put', mock_put): fm.put(path) mock_put.assert_called_once_with(path, target=None, serial=fm.serial) fm.on_put_file.emit.assert_called_once_with('foo.py')