コード例 #1
0
    def test_create_path(self, remote_tmpdir: DriveFolder):
        # depends on test_child_from_path
        depth = 3
        path = "/".join((random_string() for _ in range(0, depth)))
        folder1 = remote_tmpdir.create_path(path)
        assert folder1 == remote_tmpdir.child_from_path(path)
        folder2 = remote_tmpdir.create_path(path)
        assert folder1 == folder2

        # test . and ..
        assert remote_tmpdir.create_path(".") == remote_tmpdir
        folder = remote_tmpdir.create_path("./1/2a/../2b/")
        assert folder == remote_tmpdir.child_from_path("1/2b")
コード例 #2
0
    def test_child_from_path(self, remote_tmpdir: DriveFolder):
        depth = 3
        folder = [remote_tmpdir]
        foldername = [""]
        for i in range(1, depth + 1):
            foldername.append(random_string())
            folder.append(folder[i - 1].mkdir(foldername[i]))
        path = "/".join(foldername)
        assert remote_tmpdir.child_from_path(path) == folder[depth]

        # test . and ..
        assert remote_tmpdir.child_from_path(".") == remote_tmpdir
        path = "/".join((".", foldername[1], foldername[2], ".."))
        assert remote_tmpdir.child_from_path(path) == folder[1]
コード例 #3
0
 def test_rename_only_target_dir_no_basename(self,
                                             remote_tmpdir: DriveFolder):
     remote_file = remote_tmpdir.new_file("filename")
     remote_file.upload_empty()
     remote_tmpdir.create_path("1/2/3")
     remote_file.rename("1/2/3")
     assert remote_tmpdir.child_from_path("1/2/3/filename") == remote_file
コード例 #4
0
 def test_rename_subdir(self, remote_tmpdir: DriveFolder):
     remote_file = remote_tmpdir.new_file(random_string())
     remote_file.upload_empty()
     remote_tmpdir.create_path("1/2/3")
     remote_file.rename("1/2/3/b")
     assert remote_tmpdir.child_from_path("1/2/3/b") == remote_file