def test_FileManager_ls(): """ The on_list_files signal is emitted with a tuple of files when microfs.ls completes successfully. """ fm = FileManager("/dev/ttyUSB0") fm.serial = mock.MagicMock() fm.on_list_files = mock.MagicMock() mock_ls = mock.MagicMock(return_value=["foo.py", "bar.py"]) with mock.patch("mu.modes.base.microfs.ls", mock_ls): fm.ls() fm.on_list_files.emit.assert_called_once_with(("foo.py", "bar.py"))
def test_FileManager_delete(): """ The on_delete_file signal is emitted with the name of the effected file when microfs.rm completes successfully. """ fm = FileManager("/dev/ttyUSB0") fm.serial = mock.MagicMock() fm.on_delete_file = mock.MagicMock() mock_rm = mock.MagicMock() with mock.patch('mu.modes.base.microfs.rm', mock_rm): fm.delete('foo.py') mock_rm.assert_called_once_with('foo.py', serial=fm.serial) fm.on_delete_file.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")
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')