Back to Black
This commit is contained in:
parent
ea489bce6c
commit
5697ff87a8
112 changed files with 1803 additions and 977 deletions
|
|
@ -1347,9 +1347,13 @@ def test_get_item_returns_consumed_capacity():
|
|||
def test_put_empty_item():
|
||||
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
AttributeDefinitions=[{"AttributeName": "structure_id", "AttributeType": "S"},],
|
||||
AttributeDefinitions=[
|
||||
{"AttributeName": "structure_id", "AttributeType": "S"},
|
||||
],
|
||||
TableName="test",
|
||||
KeySchema=[{"AttributeName": "structure_id", "KeyType": "HASH"},],
|
||||
KeySchema=[
|
||||
{"AttributeName": "structure_id", "KeyType": "HASH"},
|
||||
],
|
||||
ProvisionedThroughput={"ReadCapacityUnits": 123, "WriteCapacityUnits": 123},
|
||||
)
|
||||
table = dynamodb.Table("test")
|
||||
|
|
@ -1366,9 +1370,13 @@ def test_put_empty_item():
|
|||
def test_put_item_nonexisting_hash_key():
|
||||
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
AttributeDefinitions=[{"AttributeName": "structure_id", "AttributeType": "S"},],
|
||||
AttributeDefinitions=[
|
||||
{"AttributeName": "structure_id", "AttributeType": "S"},
|
||||
],
|
||||
TableName="test",
|
||||
KeySchema=[{"AttributeName": "structure_id", "KeyType": "HASH"},],
|
||||
KeySchema=[
|
||||
{"AttributeName": "structure_id", "KeyType": "HASH"},
|
||||
],
|
||||
ProvisionedThroughput={"ReadCapacityUnits": 123, "WriteCapacityUnits": 123},
|
||||
)
|
||||
table = dynamodb.Table("test")
|
||||
|
|
@ -2287,7 +2295,10 @@ def test_update_item_on_map():
|
|||
table.update_item(
|
||||
Key={"forum_name": "the-key", "subject": "123"},
|
||||
UpdateExpression="SET body.#nested.#data = :tb",
|
||||
ExpressionAttributeNames={"#nested": "nested", "#data": "data",},
|
||||
ExpressionAttributeNames={
|
||||
"#nested": "nested",
|
||||
"#data": "data",
|
||||
},
|
||||
ExpressionAttributeValues={":tb": "new_value"},
|
||||
)
|
||||
# Running this against AWS DDB gives an exception so make sure it also fails.:
|
||||
|
|
@ -3951,19 +3962,30 @@ def test_update_supports_nested_update_if_nested_value_not_exists():
|
|||
|
||||
table = dynamodb.Table(name)
|
||||
table.put_item(
|
||||
Item={"user_id": "1234", "friends": {"5678": {"name": "friend_5678"}},},
|
||||
Item={
|
||||
"user_id": "1234",
|
||||
"friends": {"5678": {"name": "friend_5678"}},
|
||||
},
|
||||
)
|
||||
table.update_item(
|
||||
Key={"user_id": "1234"},
|
||||
ExpressionAttributeNames={"#friends": "friends", "#friendid": "0000",},
|
||||
ExpressionAttributeValues={":friend": {"name": "friend_0000"},},
|
||||
ExpressionAttributeNames={
|
||||
"#friends": "friends",
|
||||
"#friendid": "0000",
|
||||
},
|
||||
ExpressionAttributeValues={
|
||||
":friend": {"name": "friend_0000"},
|
||||
},
|
||||
UpdateExpression="SET #friends.#friendid = :friend",
|
||||
ReturnValues="UPDATED_NEW",
|
||||
)
|
||||
item = table.get_item(Key={"user_id": "1234"})["Item"]
|
||||
assert item == {
|
||||
"user_id": "1234",
|
||||
"friends": {"5678": {"name": "friend_5678"}, "0000": {"name": "friend_0000"},},
|
||||
"friends": {
|
||||
"5678": {"name": "friend_5678"},
|
||||
"0000": {"name": "friend_0000"},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4057,9 +4079,7 @@ def test_update_catches_invalid_list_append_operation():
|
|||
|
||||
# Verify correct error is returned
|
||||
str(ex.value).should.match("Parameter validation failed:")
|
||||
str(ex.value).should.match(
|
||||
"Invalid type for parameter ExpressionAttributeValues."
|
||||
)
|
||||
str(ex.value).should.match("Invalid type for parameter ExpressionAttributeValues.")
|
||||
|
||||
|
||||
def _create_user_table():
|
||||
|
|
@ -4188,11 +4208,17 @@ def test_invalid_transact_get_items():
|
|||
)
|
||||
table = dynamodb.Table("test1")
|
||||
table.put_item(
|
||||
Item={"id": "1", "val": "1",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"val": "1",
|
||||
}
|
||||
)
|
||||
|
||||
table.put_item(
|
||||
Item={"id": "1", "val": "2",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"val": "2",
|
||||
}
|
||||
)
|
||||
|
||||
client = boto3.client("dynamodb", region_name="us-east-1")
|
||||
|
|
@ -4214,16 +4240,28 @@ def test_invalid_transact_get_items():
|
|||
with pytest.raises(ClientError) as ex:
|
||||
client.transact_get_items(
|
||||
TransactItems=[
|
||||
{"Get": {"Key": {"id": {"S": "1"},}, "TableName": "test1"}},
|
||||
{"Get": {"Key": {"id": {"S": "1"},}, "TableName": "non_exists_table"}},
|
||||
{
|
||||
"Get": {
|
||||
"Key": {
|
||||
"id": {"S": "1"},
|
||||
},
|
||||
"TableName": "test1",
|
||||
}
|
||||
},
|
||||
{
|
||||
"Get": {
|
||||
"Key": {
|
||||
"id": {"S": "1"},
|
||||
},
|
||||
"TableName": "non_exists_table",
|
||||
}
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
ex.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Requested resource not found"
|
||||
)
|
||||
ex.value.response["Error"]["Message"].should.equal("Requested resource not found")
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
|
|
@ -4243,11 +4281,17 @@ def test_valid_transact_get_items():
|
|||
)
|
||||
table1 = dynamodb.Table("test1")
|
||||
table1.put_item(
|
||||
Item={"id": "1", "sort_key": "1",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"sort_key": "1",
|
||||
}
|
||||
)
|
||||
|
||||
table1.put_item(
|
||||
Item={"id": "1", "sort_key": "2",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"sort_key": "2",
|
||||
}
|
||||
)
|
||||
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4264,7 +4308,10 @@ def test_valid_transact_get_items():
|
|||
)
|
||||
table2 = dynamodb.Table("test2")
|
||||
table2.put_item(
|
||||
Item={"id": "1", "sort_key": "1",}
|
||||
Item={
|
||||
"id": "1",
|
||||
"sort_key": "1",
|
||||
}
|
||||
)
|
||||
|
||||
client = boto3.client("dynamodb", region_name="us-east-1")
|
||||
|
|
@ -4378,7 +4425,10 @@ def test_valid_transact_get_items():
|
|||
"TableName": "test1",
|
||||
"CapacityUnits": 4.0,
|
||||
"ReadCapacityUnits": 4.0,
|
||||
"Table": {"CapacityUnits": 4.0, "ReadCapacityUnits": 4.0,},
|
||||
"Table": {
|
||||
"CapacityUnits": 4.0,
|
||||
"ReadCapacityUnits": 4.0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -4387,7 +4437,10 @@ def test_valid_transact_get_items():
|
|||
"TableName": "test2",
|
||||
"CapacityUnits": 2.0,
|
||||
"ReadCapacityUnits": 2.0,
|
||||
"Table": {"CapacityUnits": 2.0, "ReadCapacityUnits": 2.0,},
|
||||
"Table": {
|
||||
"CapacityUnits": 2.0,
|
||||
"ReadCapacityUnits": 2.0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -4403,7 +4456,9 @@ def test_gsi_verify_negative_number_order():
|
|||
{"AttributeName": "gsiK1PartitionKey", "KeyType": "HASH"},
|
||||
{"AttributeName": "gsiK1SortKey", "KeyType": "RANGE"},
|
||||
],
|
||||
"Projection": {"ProjectionType": "KEYS_ONLY",},
|
||||
"Projection": {
|
||||
"ProjectionType": "KEYS_ONLY",
|
||||
},
|
||||
}
|
||||
],
|
||||
"AttributeDefinitions": [
|
||||
|
|
@ -4454,7 +4509,9 @@ def test_gsi_verify_negative_number_order():
|
|||
def test_transact_write_items_put():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4465,7 +4522,10 @@ def test_transact_write_items_put():
|
|||
TransactItems=[
|
||||
{
|
||||
"Put": {
|
||||
"Item": {"id": {"S": "foo{}".format(str(i))}, "foo": {"S": "bar"},},
|
||||
"Item": {
|
||||
"id": {"S": "foo{}".format(str(i))},
|
||||
"foo": {"S": "bar"},
|
||||
},
|
||||
"TableName": "test-table",
|
||||
}
|
||||
}
|
||||
|
|
@ -4481,14 +4541,19 @@ def test_transact_write_items_put():
|
|||
def test_transact_write_items_put_conditional_expressions():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
TableName="test-table", BillingMode="PAY_PER_REQUEST", **table_schema
|
||||
)
|
||||
dynamodb.put_item(
|
||||
TableName="test-table", Item={"id": {"S": "foo2"},},
|
||||
TableName="test-table",
|
||||
Item={
|
||||
"id": {"S": "foo2"},
|
||||
},
|
||||
)
|
||||
# Put multiple items
|
||||
with pytest.raises(ClientError) as ex:
|
||||
|
|
@ -4526,7 +4591,9 @@ def test_transact_write_items_put_conditional_expressions():
|
|||
def test_transact_write_items_conditioncheck_passes():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4534,7 +4601,10 @@ def test_transact_write_items_conditioncheck_passes():
|
|||
)
|
||||
# Insert an item without email address
|
||||
dynamodb.put_item(
|
||||
TableName="test-table", Item={"id": {"S": "foo"},},
|
||||
TableName="test-table",
|
||||
Item={
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
)
|
||||
# Put an email address, after verifying it doesn't exist yet
|
||||
dynamodb.transact_write_items(
|
||||
|
|
@ -4568,7 +4638,9 @@ def test_transact_write_items_conditioncheck_passes():
|
|||
def test_transact_write_items_conditioncheck_fails():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4617,7 +4689,9 @@ def test_transact_write_items_conditioncheck_fails():
|
|||
def test_transact_write_items_delete():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4625,12 +4699,20 @@ def test_transact_write_items_delete():
|
|||
)
|
||||
# Insert an item
|
||||
dynamodb.put_item(
|
||||
TableName="test-table", Item={"id": {"S": "foo"},},
|
||||
TableName="test-table",
|
||||
Item={
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
)
|
||||
# Delete the item
|
||||
dynamodb.transact_write_items(
|
||||
TransactItems=[
|
||||
{"Delete": {"Key": {"id": {"S": "foo"}}, "TableName": "test-table",}}
|
||||
{
|
||||
"Delete": {
|
||||
"Key": {"id": {"S": "foo"}},
|
||||
"TableName": "test-table",
|
||||
}
|
||||
}
|
||||
]
|
||||
)
|
||||
# Assert the item is deleted
|
||||
|
|
@ -4642,7 +4724,9 @@ def test_transact_write_items_delete():
|
|||
def test_transact_write_items_delete_with_successful_condition_expression():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4650,14 +4734,19 @@ def test_transact_write_items_delete_with_successful_condition_expression():
|
|||
)
|
||||
# Insert an item without email address
|
||||
dynamodb.put_item(
|
||||
TableName="test-table", Item={"id": {"S": "foo"},},
|
||||
TableName="test-table",
|
||||
Item={
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
)
|
||||
# ConditionExpression will pass - no email address has been specified yet
|
||||
dynamodb.transact_write_items(
|
||||
TransactItems=[
|
||||
{
|
||||
"Delete": {
|
||||
"Key": {"id": {"S": "foo"},},
|
||||
"Key": {
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
"TableName": "test-table",
|
||||
"ConditionExpression": "attribute_not_exists(#e)",
|
||||
"ExpressionAttributeNames": {"#e": "email_address"},
|
||||
|
|
@ -4674,7 +4763,9 @@ def test_transact_write_items_delete_with_successful_condition_expression():
|
|||
def test_transact_write_items_delete_with_failed_condition_expression():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4692,7 +4783,9 @@ def test_transact_write_items_delete_with_failed_condition_expression():
|
|||
TransactItems=[
|
||||
{
|
||||
"Delete": {
|
||||
"Key": {"id": {"S": "foo"},},
|
||||
"Key": {
|
||||
"id": {"S": "foo"},
|
||||
},
|
||||
"TableName": "test-table",
|
||||
"ConditionExpression": "attribute_not_exists(#e)",
|
||||
"ExpressionAttributeNames": {"#e": "email_address"},
|
||||
|
|
@ -4713,7 +4806,9 @@ def test_transact_write_items_delete_with_failed_condition_expression():
|
|||
def test_transact_write_items_update():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4745,7 +4840,9 @@ def test_transact_write_items_update():
|
|||
def test_transact_write_items_update_with_failed_condition_expression():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -4935,12 +5032,18 @@ def create_simple_table_and_return_client():
|
|||
dynamodb.create_table(
|
||||
TableName="moto-test",
|
||||
KeySchema=[{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
AttributeDefinitions=[{"AttributeName": "id", "AttributeType": "S"},],
|
||||
AttributeDefinitions=[
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
ProvisionedThroughput={"ReadCapacityUnits": 1, "WriteCapacityUnits": 1},
|
||||
)
|
||||
dynamodb.put_item(
|
||||
TableName="moto-test",
|
||||
Item={"id": {"S": "1"}, "myNum": {"N": "1"}, "MyStr": {"S": "1"},},
|
||||
Item={
|
||||
"id": {"S": "1"},
|
||||
"myNum": {"N": "1"},
|
||||
"MyStr": {"S": "1"},
|
||||
},
|
||||
)
|
||||
return dynamodb
|
||||
|
||||
|
|
@ -5004,7 +5107,11 @@ def test_update_expression_with_plus_in_attribute_name():
|
|||
|
||||
dynamodb.put_item(
|
||||
TableName="moto-test",
|
||||
Item={"id": {"S": "1"}, "my+Num": {"S": "1"}, "MyStr": {"S": "aaa"},},
|
||||
Item={
|
||||
"id": {"S": "1"},
|
||||
"my+Num": {"S": "1"},
|
||||
"MyStr": {"S": "aaa"},
|
||||
},
|
||||
)
|
||||
try:
|
||||
dynamodb.update_item(
|
||||
|
|
@ -5031,7 +5138,11 @@ def test_update_expression_with_minus_in_attribute_name():
|
|||
|
||||
dynamodb.put_item(
|
||||
TableName="moto-test",
|
||||
Item={"id": {"S": "1"}, "my-Num": {"S": "1"}, "MyStr": {"S": "aaa"},},
|
||||
Item={
|
||||
"id": {"S": "1"},
|
||||
"my-Num": {"S": "1"},
|
||||
"MyStr": {"S": "aaa"},
|
||||
},
|
||||
)
|
||||
try:
|
||||
dynamodb.update_item(
|
||||
|
|
@ -5058,7 +5169,11 @@ def test_update_expression_with_space_in_attribute_name():
|
|||
|
||||
dynamodb.put_item(
|
||||
TableName="moto-test",
|
||||
Item={"id": {"S": "1"}, "my Num": {"S": "1"}, "MyStr": {"S": "aaa"},},
|
||||
Item={
|
||||
"id": {"S": "1"},
|
||||
"my Num": {"S": "1"},
|
||||
"MyStr": {"S": "aaa"},
|
||||
},
|
||||
)
|
||||
|
||||
try:
|
||||
|
|
@ -5241,7 +5356,8 @@ def test_update_item_atomic_counter_from_zero():
|
|||
key = {"t_id": {"S": "item1"}}
|
||||
|
||||
ddb_mock.put_item(
|
||||
TableName=table, Item=key,
|
||||
TableName=table,
|
||||
Item=key,
|
||||
)
|
||||
|
||||
ddb_mock.update_item(
|
||||
|
|
@ -5267,7 +5383,8 @@ def test_update_item_add_to_non_existent_set():
|
|||
)
|
||||
key = {"t_id": {"S": "item1"}}
|
||||
ddb_mock.put_item(
|
||||
TableName=table, Item=key,
|
||||
TableName=table,
|
||||
Item=key,
|
||||
)
|
||||
|
||||
ddb_mock.update_item(
|
||||
|
|
@ -5292,7 +5409,8 @@ def test_update_item_add_to_non_existent_number_set():
|
|||
)
|
||||
key = {"t_id": {"S": "item1"}}
|
||||
ddb_mock.put_item(
|
||||
TableName=table, Item=key,
|
||||
TableName=table,
|
||||
Item=key,
|
||||
)
|
||||
|
||||
ddb_mock.update_item(
|
||||
|
|
@ -5309,7 +5427,9 @@ def test_update_item_add_to_non_existent_number_set():
|
|||
def test_transact_write_items_fails_with_transaction_canceled_exception():
|
||||
table_schema = {
|
||||
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"},],
|
||||
"AttributeDefinitions": [
|
||||
{"AttributeName": "id", "AttributeType": "S"},
|
||||
],
|
||||
}
|
||||
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
|
||||
dynamodb.create_table(
|
||||
|
|
@ -5361,7 +5481,9 @@ def test_gsi_projection_type_keys_only():
|
|||
{"AttributeName": "gsiK1PartitionKey", "KeyType": "HASH"},
|
||||
{"AttributeName": "gsiK1SortKey", "KeyType": "RANGE"},
|
||||
],
|
||||
"Projection": {"ProjectionType": "KEYS_ONLY",},
|
||||
"Projection": {
|
||||
"ProjectionType": "KEYS_ONLY",
|
||||
},
|
||||
}
|
||||
],
|
||||
"AttributeDefinitions": [
|
||||
|
|
@ -5414,7 +5536,9 @@ def test_lsi_projection_type_keys_only():
|
|||
{"AttributeName": "partitionKey", "KeyType": "HASH"},
|
||||
{"AttributeName": "lsiK1SortKey", "KeyType": "RANGE"},
|
||||
],
|
||||
"Projection": {"ProjectionType": "KEYS_ONLY",},
|
||||
"Projection": {
|
||||
"ProjectionType": "KEYS_ONLY",
|
||||
},
|
||||
}
|
||||
],
|
||||
"AttributeDefinitions": [
|
||||
|
|
@ -5439,7 +5563,8 @@ def test_lsi_projection_type_keys_only():
|
|||
table.put_item(Item=item)
|
||||
|
||||
items = table.query(
|
||||
KeyConditionExpression=Key("partitionKey").eq("pk-1"), IndexName="LSI",
|
||||
KeyConditionExpression=Key("partitionKey").eq("pk-1"),
|
||||
IndexName="LSI",
|
||||
)["Items"]
|
||||
items.should.have.length_of(1)
|
||||
# Item should only include GSI Keys and Table Keys, as per the ProjectionType
|
||||
|
|
|
|||
|
|
@ -211,7 +211,11 @@ def test_execution_of_remove_in_map():
|
|||
"itemlist": {
|
||||
"L": [
|
||||
{"M": {"foo00": {"S": "bar1"}, "foo01": {"S": "bar2"}}},
|
||||
{"M": {"foo10": {"S": "bar1"},}},
|
||||
{
|
||||
"M": {
|
||||
"foo10": {"S": "bar1"},
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -260,7 +264,9 @@ def test_execution_of_remove_in_list():
|
|||
"itemmap": {
|
||||
"M": {
|
||||
"itemlist": {
|
||||
"L": [{"M": {"foo00": {"S": "bar1"}, "foo01": {"S": "bar2"}}},]
|
||||
"L": [
|
||||
{"M": {"foo00": {"S": "bar1"}, "foo01": {"S": "bar2"}}},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -277,7 +283,10 @@ def test_execution_of_delete_element_from_set():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"SS": ["value1", "value2", "value3"]},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"SS": ["value1", "value2", "value3"]},
|
||||
},
|
||||
)
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
update_expression_ast,
|
||||
|
|
@ -291,7 +300,10 @@ def test_execution_of_delete_element_from_set():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"SS": ["value1", "value3"]},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"SS": ["value1", "value3"]},
|
||||
},
|
||||
)
|
||||
assert expected_item == item
|
||||
|
||||
|
|
@ -304,7 +316,10 @@ def test_execution_of_add_number():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"N": "5"},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"N": "5"},
|
||||
},
|
||||
)
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
update_expression_ast,
|
||||
|
|
@ -331,7 +346,10 @@ def test_execution_of_add_set_to_a_number():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"N": "5"},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"N": "5"},
|
||||
},
|
||||
)
|
||||
try:
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
|
|
@ -362,7 +380,10 @@ def test_execution_of_add_to_a_set():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"SS": ["value1", "value2", "value3"]},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"SS": ["value1", "value2", "value3"]},
|
||||
},
|
||||
)
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
update_expression_ast,
|
||||
|
|
@ -386,13 +407,34 @@ def test_execution_of_add_to_a_set():
|
|||
|
||||
@parameterized(
|
||||
[
|
||||
({":value": {"S": "10"}}, "STRING",),
|
||||
({":value": {"N": "10"}}, "NUMBER",),
|
||||
({":value": {"B": "10"}}, "BINARY",),
|
||||
({":value": {"BOOL": True}}, "BOOLEAN",),
|
||||
({":value": {"NULL": True}}, "NULL",),
|
||||
({":value": {"M": {"el0": {"S": "10"}}}}, "MAP",),
|
||||
({":value": {"L": []}}, "LIST",),
|
||||
(
|
||||
{":value": {"S": "10"}},
|
||||
"STRING",
|
||||
),
|
||||
(
|
||||
{":value": {"N": "10"}},
|
||||
"NUMBER",
|
||||
),
|
||||
(
|
||||
{":value": {"B": "10"}},
|
||||
"BINARY",
|
||||
),
|
||||
(
|
||||
{":value": {"BOOL": True}},
|
||||
"BOOLEAN",
|
||||
),
|
||||
(
|
||||
{":value": {"NULL": True}},
|
||||
"NULL",
|
||||
),
|
||||
(
|
||||
{":value": {"M": {"el0": {"S": "10"}}}},
|
||||
"MAP",
|
||||
),
|
||||
(
|
||||
{":value": {"L": []}},
|
||||
"LIST",
|
||||
),
|
||||
]
|
||||
)
|
||||
def test_execution_of__delete_element_from_set_invalid_value(
|
||||
|
|
@ -406,7 +448,10 @@ def test_execution_of__delete_element_from_set_invalid_value(
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"SS": ["value1", "value2", "value3"]},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"SS": ["value1", "value2", "value3"]},
|
||||
},
|
||||
)
|
||||
try:
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
|
|
@ -431,7 +476,10 @@ def test_execution_of_delete_element_from_a_string_attribute():
|
|||
hash_key_type="TYPE",
|
||||
range_key=None,
|
||||
range_key_type=None,
|
||||
attrs={"id": {"S": "foo2"}, "s": {"S": "5"},},
|
||||
attrs={
|
||||
"id": {"S": "foo2"},
|
||||
"s": {"S": "5"},
|
||||
},
|
||||
)
|
||||
try:
|
||||
validated_ast = UpdateExpressionValidator(
|
||||
|
|
|
|||
|
|
@ -42,7 +42,10 @@ def test_validation_of_update_expression_with_keyword():
|
|||
|
||||
|
||||
@parameterized(
|
||||
["SET a = #b + :val2", "SET a = :val2 + #b",]
|
||||
[
|
||||
"SET a = #b + :val2",
|
||||
"SET a = :val2 + #b",
|
||||
]
|
||||
)
|
||||
def test_validation_of_a_set_statement_with_incorrect_passed_value(update_expression):
|
||||
"""
|
||||
|
|
@ -99,7 +102,10 @@ def test_validation_of_update_expression_with_attribute_that_does_not_exist_in_i
|
|||
|
||||
|
||||
@parameterized(
|
||||
["SET a = #c", "SET a = #c + #d",]
|
||||
[
|
||||
"SET a = #c",
|
||||
"SET a = #c + #d",
|
||||
]
|
||||
)
|
||||
def test_validation_of_update_expression_with_attribute_name_that_is_not_defined(
|
||||
update_expression,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue