pyPhotoAlbum/tests/test_version_roundtrip.py
Duncan Tourolle 0d698a83b4
Some checks failed
Python CI / test (push) Successful in 55s
Lint / lint (push) Successful in 1m31s
Tests / test (3.10) (push) Failing after 44s
Tests / test (3.11) (push) Failing after 42s
Tests / test (3.9) (push) Failing after 42s
large change to allow project merging
2025-11-23 00:33:42 +01:00

41 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Test version round-trip: save with current version, load with current version (no migration needed)
"""
import os
import tempfile
import shutil
from pyPhotoAlbum.project import Project
from pyPhotoAlbum.project_serializer import save_to_zip, load_from_zip
from pyPhotoAlbum.version_manager import CURRENT_DATA_VERSION
def test_version_roundtrip():
"""Test that we can save and load a project without migration"""
# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp(prefix="pyphotos_test_")
test_ppz = os.path.join(temp_dir, "test_project.ppz")
try:
# Create a new project
project = Project("Test Project")
# Save it
success, error = save_to_zip(project, test_ppz)
assert success, f"Failed to save: {error}"
assert os.path.exists(test_ppz), f"ZIP file not created: {test_ppz}"
# Load it back
loaded_project = load_from_zip(test_ppz)
# Verify the loaded project
assert loaded_project is not None, "Failed to load project"
assert loaded_project.name == "Test Project", f"Project name mismatch: {loaded_project.name}"
assert loaded_project.folder_path is not None, "Project folder path is None"
finally:
# Cleanup
if os.path.exists(temp_dir):
shutil.rmtree(temp_dir)