mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
More work on file transfer
This commit is contained in:
@@ -360,6 +360,15 @@ class TestFileTransmission(BaseTest):
|
||||
kw = {str(k): expand_home(str(v)) for k, v in kw.items()}
|
||||
self.ae(kw, m)
|
||||
|
||||
def gm(all_specs):
|
||||
specs = list((str(i), str(s)) for i, s in enumerate(all_specs))
|
||||
files = []
|
||||
for x in iter_file_metadata(specs):
|
||||
if isinstance(x, Exception):
|
||||
raise x
|
||||
files.append(File(x))
|
||||
return files, specs
|
||||
|
||||
def tf(args, expected, different_home=''):
|
||||
if opts.mode == 'mirror':
|
||||
all_specs = args
|
||||
@@ -367,8 +376,7 @@ class TestFileTransmission(BaseTest):
|
||||
else:
|
||||
all_specs = args[:-1]
|
||||
dest = args[-1]
|
||||
specs = list((str(i), str(s)) for i, s in enumerate(all_specs))
|
||||
files = list(map(File, iter_file_metadata(specs)))
|
||||
files, specs = gm(all_specs)
|
||||
orig_home = home_path()
|
||||
with set_paths(cwd_path(), different_home or orig_home):
|
||||
files = list(files_for_receive(opts, dest, files, orig_home, specs))
|
||||
@@ -382,6 +390,21 @@ class TestFileTransmission(BaseTest):
|
||||
with set_paths(cwd=b, home=self.tdir):
|
||||
tf([b/'r', b/'d'], {b/'r': '~/b/r', b/'d': '~/b/d', b/'d'/'r': '~/b/d/r'}, different_home='/foo/bar')
|
||||
opts.mode = 'normal'
|
||||
with set_paths(cwd='/some/else', home='/foo/bar'):
|
||||
tf([b/'r', b/'d', '/dest'], {b/'r': '/dest/r', b/'d': '/dest/d', b/'d'/'r': '/dest/d/r'})
|
||||
tf([b/'r', b/'d', '~/dest'], {b/'r': '~/dest/r', b/'d': '~/dest/d', b/'d'/'r': '~/dest/d/r'})
|
||||
with set_paths(cwd=b, home='/foo/bar'):
|
||||
tf([b/'r', b/'d', '/dest'], {b/'r': '/dest/r', b/'d': '/dest/d', b/'d'/'r': '/dest/d/r'})
|
||||
os.symlink('/foo/b', b / 'e')
|
||||
os.symlink('r', b / 's')
|
||||
os.link(b / 'r', b / 'h')
|
||||
with set_paths(cwd='/some/else', home='/foo/bar'):
|
||||
files = gm((b/'e', b/'s', b/'r', b / 'h'))[0]
|
||||
self.assertEqual(files[0].ftype, FileType.symlink)
|
||||
self.assertEqual(files[1].ftype, FileType.symlink)
|
||||
self.assertEqual(files[1].remote_target, files[2].remote_id)
|
||||
self.assertEqual(files[3].ftype, FileType.link)
|
||||
self.assertEqual(files[3].remote_target, files[2].remote_id)
|
||||
|
||||
def test_path_mapping_send(self):
|
||||
opts = parse_transfer_args([])[0]
|
||||
|
||||
Reference in New Issue
Block a user