#!/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)