Skip to content

Commit

Permalink
DynamoDB: Verify batch-size URL parameter
Browse files Browse the repository at this point in the history
This software test verifies that the URL parameter is correctly
propagated to the relevant incantation.
  • Loading branch information
amotl committed Oct 23, 2024
1 parent 63987e5 commit db67cd1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/io/dynamodb/test_copy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import Mock

import pytest

from cratedb_toolkit.io.dynamodb.copy import DynamoDBFullLoad
Expand Down Expand Up @@ -79,3 +81,31 @@ def test_dynamodb_copy_basic_warning(caplog, cratedb, dynamodb, dynamodb_test_ma
assert results == data_out

assert "Dynamic nested arrays are not supported" in caplog.text


def test_dynamodb_copy_verify_batch_size(caplog, cratedb, dynamodb, dynamodb_test_manager):
"""
Verify that the `batch-size` parameter on the DynamoDB URL works as expected.
"""

ddb_document = {
"Id": {"N": "101"},
"Name": {"S": "Hotzenplotz"},
}

# Define source and target URLs.
dynamodb_url = f"{dynamodb.get_connection_url_dynamodb()}/demo?region=us-east-1&batch-size=1234"
cratedb_url = f"{cratedb.get_connection_url()}/testdrive/demo"

# Define transfer.
table_loader = DynamoDBFullLoad(dynamodb_url=dynamodb_url, cratedb_url=cratedb_url)

# Define a mock for the `.scan()` method.
mock_scan = Mock(return_value={"Items": [ddb_document], "Count": 1})
table_loader.dynamodb_adapter.dynamodb_client.scan = mock_scan

# Invoke transfer.
table_loader.start()

# Verify invocation of `.scan()` command.
mock_scan.assert_called_with(TableName="demo", ConsistentRead=False, Limit=1234)

0 comments on commit db67cd1

Please sign in to comment.