From c3d385bf1843a949a66580e6c8c0e8c0fe522801 Mon Sep 17 00:00:00 2001 From: Simone Scarduzio Date: Mon, 13 Oct 2025 17:26:35 +0200 Subject: [PATCH] fix tests --- src/deltaglider/app/cli/aws_compat.py | 19 ++++++++++-------- tests/integration/test_s3_migration.py | 27 +++++++++++++------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/deltaglider/app/cli/aws_compat.py b/src/deltaglider/app/cli/aws_compat.py index 35c2b72..2e2d8ee 100644 --- a/src/deltaglider/app/cli/aws_compat.py +++ b/src/deltaglider/app/cli/aws_compat.py @@ -318,7 +318,7 @@ def migrate_s3_to_s3( max_ratio: float | None = None, dry_run: bool = False, skip_confirm: bool = False, - preserve_prefix: bool = True, + preserve_prefix: bool = False, region_override: bool = False, ) -> None: """Migrate objects from one S3 location to another with delta compression. @@ -450,19 +450,22 @@ def migrate_s3_to_s3( if len(dest_keys) > 0: click.echo(f"Already migrated: {len(dest_keys)} files (will be skipped)") - if dry_run: + # Handle dry run mode early (before confirmation prompt) + if dry_run: + if not quiet: click.echo("\n--- DRY RUN MODE ---") for _obj, rel_key in files_to_migrate[:10]: # Show first 10 files click.echo(f" Would migrate: {rel_key}") if len(files_to_migrate) > 10: click.echo(f" ... and {len(files_to_migrate) - 10} more files") - return + return - if not skip_confirm: - click.echo("") - if not click.confirm("Do you want to proceed with the migration?"): - click.echo("Migration cancelled.") - return + # Ask for confirmation before proceeding with actual migration + if not quiet and not skip_confirm: + click.echo("") + if not click.confirm("Do you want to proceed with the migration?"): + click.echo("Migration cancelled.") + return # Perform migration if not quiet: diff --git a/tests/integration/test_s3_migration.py b/tests/integration/test_s3_migration.py index d2e02c4..6942357 100644 --- a/tests/integration/test_s3_migration.py +++ b/tests/integration/test_s3_migration.py @@ -110,21 +110,22 @@ def test_migrate_s3_to_s3_dry_run(mock_service): mock_service.storage.list.return_value = iter(source_objects) - # Mock the copy operation + # Mock the copy operation and EC2 detection with patch("deltaglider.app.cli.aws_compat.copy_s3_to_s3") as mock_copy: with patch("deltaglider.app.cli.aws_compat.click.echo") as mock_echo: - migrate_s3_to_s3( - mock_service, - "s3://source-bucket/", - "s3://dest-bucket/", - exclude=None, - include=None, - quiet=True, # Skip EC2 detection - no_delta=False, - max_ratio=None, - dry_run=True, - skip_confirm=False, - ) + with patch("deltaglider.app.cli.aws_compat.log_aws_region"): + migrate_s3_to_s3( + mock_service, + "s3://source-bucket/", + "s3://dest-bucket/", + exclude=None, + include=None, + quiet=False, # Allow output to test dry run messages + no_delta=False, + max_ratio=None, + dry_run=True, + skip_confirm=False, + ) # Should not actually copy anything in dry run mode mock_copy.assert_not_called()