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