bytedance-1 / test_symlinks.py
drdata's picture
Upload folder using huggingface_hub
02831c4 verified
#!/usr/bin/env python3
"""
Test script to verify symbolic links work for BytePlus directories
"""
import os
from pathlib import Path
def test_directory_access():
"""Test that all required directories are accessible through symbolic links."""
print("πŸ§ͺ Testing BytePlus directory access through symbolic links...")
# Test directories
test_dirs = [
".cache/Generated",
".cache/static",
".cache/view_session",
".cache/static/css",
".cache/static/js",
".cache/static/images"
]
all_passed = True
for test_dir in test_dirs:
dir_path = Path(test_dir)
# Test directory existence
if dir_path.exists():
print(f"βœ… Directory exists: {test_dir}")
else:
print(f"❌ Directory missing: {test_dir}")
all_passed = False
continue
# Test write permission
try:
test_file = dir_path / "test_write.tmp"
test_file.write_text("test content")
if test_file.read_text() == "test content":
print(f"βœ… Write/Read access: {test_dir}")
test_file.unlink() # Clean up
else:
print(f"❌ Read verification failed: {test_dir}")
all_passed = False
except Exception as e:
print(f"❌ Write access failed for {test_dir}: {e}")
all_passed = False
# Test symbolic link verification
symlink_dirs = [".cache/Generated", ".cache/static", ".cache/view_session"]
for symlink_dir in symlink_dirs:
link_path = Path(symlink_dir)
if link_path.is_symlink():
target = link_path.readlink()
print(f"πŸ”— Symlink verified: {symlink_dir} -> {target}")
else:
print(f"⚠️ Not a symlink: {symlink_dir}")
all_passed = False
if all_passed:
print("\nπŸŽ‰ All tests passed! Symbolic link approach is working correctly.")
print("βœ… BytePlus app will be able to access Generated/, static/, and view_session/ directories")
print("βœ… View session functionality should work properly")
print("βœ… File downloads will be stored in the correct directories")
else:
print("\n❌ Some tests failed. Please check the directory setup.")
return all_passed
if __name__ == "__main__":
success = test_directory_access()
exit(0 if success else 1)