Skip to content

Commit

Permalink
Add new tests for cloud transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
amritghimire committed Feb 13, 2025
1 parent f918e39 commit 04511f3
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/func/test_cloud_transfer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pytest

from datachain.client import Client
from datachain.lib.dc import DataChain


@pytest.mark.parametrize(
"src_cloud_type,dst_cloud_type",
[
("azure", "gs"),
("gs", "azure"),
("s3", "gs"),
("gs", "s3"),
],
indirect=["src_cloud_type"],
)
def test_cross_cloud_transfer(
cloud_test_catalog_upload,
cloud_type,
src_cloud_type,
dst_cloud_type,
tmp_upath_factory,
):
# Setup source and destination paths
src_path = tmp_upath_factory.mktemp(src_cloud_type)
dst_path = tmp_upath_factory.mktemp(dst_cloud_type)

# Create test file in source
test_content = b"test content"
(src_path / "test.txt").write_bytes(test_content)

# Create DataChain and transfer
ds = DataChain.from_storage(f"{src_cloud_type}://{src_path}/test.txt")
ds.to_storage(f"{dst_cloud_type}://{dst_path}/destination", placement="filename")

# Verify transfer
dst_client = Client.get_client(f"{dst_cloud_type}://{dst_path}", None)
assert dst_client.fs.exists(f"{dst_path}/destination/test.txt")

transferred_content = dst_client.fs.read_bytes(f"{dst_path}/destination/test.txt")
assert transferred_content == test_content

0 comments on commit 04511f3

Please sign in to comment.