51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test to demonstrate the asset drop bug
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from pyPhotoAlbum.project import Project, Page
|
|
from pyPhotoAlbum.models import ImageData
|
|
|
|
def test_direct_path_assignment():
|
|
"""Simulate what happens when you drop an image on existing element"""
|
|
|
|
project = Project("Test Direct Path")
|
|
page = Page()
|
|
project.add_page(page)
|
|
|
|
# Add an image element
|
|
img = ImageData()
|
|
img.position = (10, 10)
|
|
img.size = (50, 50)
|
|
page.layout.add_element(img)
|
|
|
|
# Simulate dropping a new image on existing element (line 77 in asset_drop.py)
|
|
external_image = "/home/dtourolle/Pictures/some_photo.jpg"
|
|
print(f"\nSimulating drop on existing image element...")
|
|
print(f"Setting image_path directly to: {external_image}")
|
|
img.image_path = external_image # BUG: Not imported!
|
|
|
|
# Check assets folder
|
|
assets = os.listdir(project.asset_manager.assets_folder) if os.path.exists(project.asset_manager.assets_folder) else []
|
|
print(f"\nAssets in folder: {len(assets)}")
|
|
print(f" {assets if assets else '(empty)'}")
|
|
|
|
# The image path in the element points to external file
|
|
print(f"\nImage path in element: {img.image_path}")
|
|
print(f" Is absolute path: {os.path.isabs(img.image_path)}")
|
|
|
|
if os.path.isabs(img.image_path):
|
|
print("\n❌ BUG CONFIRMED: Image path is absolute, not copied to assets!")
|
|
print(" When saved to .ppz, this external file will NOT be included.")
|
|
return False
|
|
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
test_direct_path_assignment()
|