def _move_existing_and_download(self, item_local_path, remote_item, all_local_items, q): """ Rename existing file and download the remote item there. :param str item_local_path: :param onedrived.api.items.OneDriveItem remote_item: :param [str] all_local_items: :param dict[str, onedrived.api.items.OneDriveItem] q: """ try: resolved_name = append_hostname(item_local_path) all_local_items.add(resolved_name) if len(q) > 0: self.items_store.delete_item(parent_path=self.remote_path, item_name=remote_item.name) self._create_download_task(item_local_path, remote_item) except (IOError, OSError) as e: self.logger.error('IO error when renaming renaming "%s": %s.', item_local_path, e)
def test_append_hostname_number(self): with mock.patch('os.path.exists', side_effect=[True, True, False]): self.assertEqual('file 2 (%s)' % OS_HOSTNAME, utils.append_hostname('file'))
def test_append_hostname_no_number(self): os.path.exists = lambda p: False self.assertEqual('file (%s)' % OS_HOSTNAME, utils.append_hostname('file'))