diff options
author | Ryo Nakamura <upa@haeena.net> | 2022-11-18 14:42:23 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2022-11-18 20:20:19 +0900 |
commit | 5e7aa774cafef00e2ec911ec978f07acedeadcae (patch) | |
tree | 71b082e74a365aba23552e73c140a7d912b9b581 /test | |
parent | b8d58b1fba1d29d36b98dd19e544ff3002b286e4 (diff) |
fix when copy multiple sources and various tiny fixes
* when copying multiple sources, target must be directory
* add multi-src copy test and parametrize src/dst prefixes
* cleanup REAMDE (s/sessions/connections/g)
* make error output in copy functions simple
Diffstat (limited to 'test')
-rw-r--r-- | test/test_e2e.py | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/test/test_e2e.py b/test/test_e2e.py index 5fa0ea7..61a3532 100644 --- a/test/test_e2e.py +++ b/test/test_e2e.py @@ -29,6 +29,7 @@ param_invalid_hostnames = [ (["a:a", "b:b", "c:c"]), (["a:a", "b:b", "c"]), (["a:a", "b", "c:c"]), (["a", "b:b", "c:c"]) ] + @pytest.mark.parametrize("args", param_invalid_hostnames) def test_nonidentical_hostnames(mscp, args): run2ng([mscp] + args) @@ -39,6 +40,9 @@ def test_nonidentical_hostnames(mscp, args): """ copy test """ remote_prefix = "localhost:{}/".format(os.getcwd()) # use current dir +param_remote_prefix = [ + ("", remote_prefix), (remote_prefix, "") +] param_single_copy = [ (File("src", size = 64), File("dst")), @@ -46,23 +50,33 @@ param_single_copy = [ (File("src", size = 128 * 1024 * 1024), File("dst")), ] +@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix) @pytest.mark.parametrize("src, dst", param_single_copy) -def test_single_copy_remote2local(mscp, src, dst): - src.make() - run2ok([mscp, "-H", remote_prefix + src.path, dst.path]) - assert check_same_md5sum(src, dst) - src.cleanup() - dst.cleanup() - -@pytest.mark.parametrize("src, dst", param_single_copy) -def test_single_copy_local2remote(mscp, src, dst): +def test_single_copy(mscp, src_prefix, dst_prefix, src, dst): src.make() - run2ok([mscp, "-H", src.path, remote_prefix + dst.path]) + run2ok([mscp, "-H", src_prefix + src.path, dst_prefix + dst.path]) assert check_same_md5sum(src, dst) src.cleanup() dst.cleanup() +param_double_copy = [ + (File("src1", size = 1024 * 1024), File("src2", size = 1024 * 1024), + File("dst/src1"), File("dst/src2") + ) +] +@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix) +@pytest.mark.parametrize("s1, s2, d1, d2", param_double_copy) +def test_double_copy(mscp, src_prefix, dst_prefix, s1, s2, d1, d2): + s1.make() + s2.make() + run2ok([mscp, "-H", src_prefix + s1.path, src_prefix + s2.path, dst_prefix + "dst"]) + assert check_same_md5sum(s1, d1) + assert check_same_md5sum(s2, d2) + s1.cleanup() + s2.cleanup() + d1.cleanup() + d2.cleanup() param_dir_copy = [ ( "src_dir", "dst_dir", @@ -87,34 +101,17 @@ does not exist. If dst_dir exists, scp copies src_dir to dst_dir/src_dir. So, this test checks both cases. """ +@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix) @pytest.mark.parametrize("src_dir, dst_dir, src, dst, twice", param_dir_copy) -def test_dir_copy_remote2local(mscp, src_dir, dst_dir, src, dst, twice): - for f in src: - f.make() - - run2ok([mscp, "-H", remote_prefix + src_dir, dst_dir]) - for sf, df in zip(src, dst): - assert check_same_md5sum(sf, df) - - run2ok([mscp, "-H", remote_prefix + src_dir, dst_dir]) - for sf, df in zip(src, twice): - assert check_same_md5sum(sf, df) - - for sf, df, tf in zip(src, dst, twice): - sf.cleanup() - df.cleanup() - tf.cleanup() - -@pytest.mark.parametrize("src_dir, dst_dir, src, dst, twice", param_dir_copy) -def test_dir_copy_local2remote(mscp, src_dir, dst_dir, src, dst, twice): +def test_dir_copy(mscp, src_prefix, dst_prefix, src_dir, dst_dir, src, dst, twice): for f in src: f.make() - run2ok([mscp, "-H", src_dir, remote_prefix + dst_dir]) + run2ok([mscp, "-H", src_prefix + src_dir, dst_prefix + dst_dir]) for sf, df in zip(src, dst): assert check_same_md5sum(sf, df) - run2ok([mscp, "-H", src_dir, remote_prefix + dst_dir]) + run2ok([mscp, "-H", src_prefix + src_dir, dst_prefix + dst_dir]) for sf, df in zip(src, twice): assert check_same_md5sum(sf, df) @@ -123,10 +120,6 @@ def test_dir_copy_local2remote(mscp, src_dir, dst_dir, src, dst, twice): df.cleanup() tf.cleanup() - -param_remote_prefix = [ - ("", remote_prefix), (remote_prefix, "") -] @pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix) def test_override_single_file(mscp, src_prefix, dst_prefix): src = File("src", size = 128).make() |