get rid of legacy commands

This commit is contained in:
Simone Scarduzio
2025-10-03 19:12:50 +02:00
parent 03106b76a8
commit b760890a61
7 changed files with 27 additions and 317 deletions

View File

@@ -72,7 +72,7 @@ class TestLocalStackE2E:
file2.write_text("Plugin version 1.0.1 content with minor changes")
# Upload first file (becomes reference)
result = runner.invoke(cli, ["put", str(file1), f"s3://{test_bucket}/plugins/"])
result = runner.invoke(cli, ["cp", str(file1), f"s3://{test_bucket}/plugins/"])
assert result.exit_code == 0
output1 = extract_json_from_cli_output(result.output)
assert output1["operation"] == "create_reference"
@@ -85,7 +85,7 @@ class TestLocalStackE2E:
assert "plugins/plugin-v1.0.0.zip.delta" in keys
# Upload second file (creates delta)
result = runner.invoke(cli, ["put", str(file2), f"s3://{test_bucket}/plugins/"])
result = runner.invoke(cli, ["cp", str(file2), f"s3://{test_bucket}/plugins/"])
assert result.exit_code == 0
output2 = extract_json_from_cli_output(result.output)
assert output2["operation"] == "create_delta"
@@ -97,9 +97,8 @@ class TestLocalStackE2E:
result = runner.invoke(
cli,
[
"get",
"cp",
f"s3://{test_bucket}/plugins/plugin-v1.0.1.zip.delta",
"-o",
str(output_file),
],
)
@@ -130,10 +129,10 @@ class TestLocalStackE2E:
file_b1.write_text("Application B version 1")
# Upload to different deltaspaces
result = runner.invoke(cli, ["put", str(file_a1), f"s3://{test_bucket}/apps/app-a/"])
result = runner.invoke(cli, ["cp", str(file_a1), f"s3://{test_bucket}/apps/app-a/"])
assert result.exit_code == 0
result = runner.invoke(cli, ["put", str(file_b1), f"s3://{test_bucket}/apps/app-b/"])
result = runner.invoke(cli, ["cp", str(file_b1), f"s3://{test_bucket}/apps/app-b/"])
assert result.exit_code == 0
# Verify each deltaspace has its own reference
@@ -160,14 +159,14 @@ class TestLocalStackE2E:
file2.write_text("B" * 1000) # Completely different
# Upload first file
result = runner.invoke(cli, ["put", str(file1), f"s3://{test_bucket}/test/"])
result = runner.invoke(cli, ["cp", str(file1), f"s3://{test_bucket}/test/"])
assert result.exit_code == 0
# Upload second file with low max-ratio
result = runner.invoke(
cli,
[
"put",
"cp",
str(file2),
f"s3://{test_bucket}/test/",
"--max-ratio",

View File

@@ -1,146 +0,0 @@
"""Integration test for get command."""
import tempfile
from pathlib import Path
from unittest.mock import Mock, patch
import pytest
from click.testing import CliRunner
from deltaglider.app.cli.main import cli
from deltaglider.core import ObjectKey
@pytest.fixture
def mock_service():
"""Create a mock DeltaService."""
return Mock()
def test_get_command_with_original_name(mock_service):
"""Test get command with original filename (auto-appends .delta)."""
runner = CliRunner()
# Mock the service.get method and storage.head
mock_service.get = Mock()
mock_service.storage.head = Mock(
side_effect=[
None, # First check for original file returns None
Mock(), # Second check for .delta file returns something
]
)
with patch("deltaglider.app.cli.main.create_service", return_value=mock_service):
# Run get with original filename (should auto-append .delta)
result = runner.invoke(cli, ["get", "s3://test-bucket/data/myfile.zip"])
# Check it was successful
assert result.exit_code == 0
assert "Found delta file: s3://test-bucket/data/myfile.zip.delta" in result.output
assert "Successfully retrieved: myfile.zip" in result.output
# Verify the service was called with the correct arguments
mock_service.get.assert_called_once()
call_args = mock_service.get.call_args
obj_key = call_args[0][0]
output_path = call_args[0][1]
assert isinstance(obj_key, ObjectKey)
assert obj_key.bucket == "test-bucket"
assert obj_key.key == "data/myfile.zip.delta"
assert output_path == Path("myfile.zip")
def test_get_command_with_delta_name(mock_service):
"""Test get command with explicit .delta filename."""
runner = CliRunner()
# Mock the service.get method and storage.head
mock_service.get = Mock()
mock_service.storage.head = Mock(return_value=Mock()) # File exists
with patch("deltaglider.app.cli.main.create_service", return_value=mock_service):
# Run get with explicit .delta filename
result = runner.invoke(cli, ["get", "s3://test-bucket/data/myfile.zip.delta"])
# Check it was successful
assert result.exit_code == 0
assert "Found file: s3://test-bucket/data/myfile.zip.delta" in result.output
assert "Successfully retrieved: myfile.zip" in result.output
# Verify the service was called with the correct arguments
mock_service.get.assert_called_once()
call_args = mock_service.get.call_args
obj_key = call_args[0][0]
output_path = call_args[0][1]
assert isinstance(obj_key, ObjectKey)
assert obj_key.bucket == "test-bucket"
assert obj_key.key == "data/myfile.zip.delta"
assert output_path == Path("myfile.zip")
def test_get_command_with_output_option(mock_service):
"""Test get command with custom output path."""
runner = CliRunner()
# Mock the service.get method and storage.head
mock_service.get = Mock()
mock_service.storage.head = Mock(
side_effect=[
None, # First check for original file returns None
Mock(), # Second check for .delta file returns something
]
)
with patch("deltaglider.app.cli.main.create_service", return_value=mock_service):
with tempfile.TemporaryDirectory() as tmpdir:
output_file = Path(tmpdir) / "custom_output.zip"
# Run get with custom output path
result = runner.invoke(
cli, ["get", "s3://test-bucket/data/myfile.zip", "-o", str(output_file)]
)
# Check it was successful
assert result.exit_code == 0
assert f"Successfully retrieved: {output_file}" in result.output
# Verify the service was called with the correct arguments
mock_service.get.assert_called_once()
call_args = mock_service.get.call_args
obj_key = call_args[0][0]
output_path = call_args[0][1]
assert isinstance(obj_key, ObjectKey)
assert obj_key.bucket == "test-bucket"
assert obj_key.key == "data/myfile.zip.delta"
assert output_path == output_file
def test_get_command_error_handling(mock_service):
"""Test get command error handling."""
runner = CliRunner()
# Mock the service.get method to raise an error
mock_service.get = Mock(side_effect=FileNotFoundError("Delta not found"))
with patch("deltaglider.app.cli.main.create_service", return_value=mock_service):
# Run get command
result = runner.invoke(cli, ["get", "s3://test-bucket/data/missing.zip"])
# Check it failed with error message
assert result.exit_code == 1
assert "Error: Delta not found" in result.output
def test_get_command_invalid_url():
"""Test get command with invalid S3 URL."""
runner = CliRunner()
# Run get with invalid URL
result = runner.invoke(cli, ["get", "http://invalid-url/file.zip"])
# Check it failed with error message
assert result.exit_code == 1
assert "Error: Invalid S3 URL" in result.output