def test_storage_disk_mkdir(): root_path = generate_folder_path() assert isdir(root_path) s = StorageDisk(root_path=root_path) assert s.initialized() s.mkdir("/tmp1") assert isdir(root_path / "tmp1") s.mkdir("tmp2") assert isdir(root_path / "tmp2") tmp_folders = [x.name for x in root_path.iterdir()] assert sorted(tmp_folders) == ["tmp1", "tmp2"] tmp_mtime = getmtime(root_path / "tmp2") try: s.mkdir("tmp2") except Exception as e: print(e) assert tmp_mtime == getmtime(root_path / "tmp2") s.mkdir("tmp/tmp3") assert isdir(root_path / "tmp/tmp3") assert isdir(root_path / "tmp") remove_folder(root_path)
def test_storage_disk_mkdir_cd_pwd(): root_path = generate_folder_path() assert isdir(root_path) s = StorageDisk(root_path=root_path) assert s.initialized() s.mkdir("level1/level2") s.mkdir("/level1/level2/level3") assert isdir(root_path / "level1/level2/level3") s.cd("level1") assert s.pwd() == "/level1" s.cd("level2") assert s.pwd() == "/level1/level2" s.cd("/level1/level2/level3") assert s.pwd() == "/level1/level2/level3" s.mkdir("level4") assert isdir(root_path / "level1/level2/level3/level4") s.cd("..") assert s.pwd() == "/level1/level2" s.cd("../..") assert s.pwd() == "/" try: s.cd("../..") except Exception as e: print(e) assert s.pwd() == "/" s.mkdir("tmp") isdir(root_path / "tmp") remove_folder(root_path)