def test_forbidden_tags_from_creation(scylla_only, dynamodb): # The feature of creating a table already with tags was only added to # DynamoDB in April 2019, and to the botocore library in version 1.12.136 # so older versions of the library cannot run this test. import botocore from distutils.version import LooseVersion if (LooseVersion(botocore.__version__) < LooseVersion('1.12.136')): pytest.skip( "Botocore version 1.12.136 or above required to run this test") name = test_table_name() # It is not allowed to set the system:write_isolation to "dog", so the # following table creation should fail: with pytest.raises(ClientError, match='ValidationException'): dynamodb.create_table(TableName=name, BillingMode='PAY_PER_REQUEST', KeySchema=[{ 'AttributeName': 'p', 'KeyType': 'HASH' }], AttributeDefinitions=[{ 'AttributeName': 'p', 'AttributeType': 'S' }], Tags=[{ 'Key': 'system:write_isolation', 'Value': 'dog' }]) # After the table creation failed, the table should not exist. with pytest.raises(ClientError, match='ResourceNotFoundException'): dynamodb.meta.client.describe_table(TableName=name)
def test_create_table_billing_mode_errors(dynamodb, test_table): with pytest.raises(ClientError, match='ValidationException'): create_table(dynamodb, test_table_name(), BillingMode='unknown') # billing mode is case-sensitive with pytest.raises(ClientError, match='ValidationException'): create_table(dynamodb, test_table_name(), BillingMode='pay_per_request') # PAY_PER_REQUEST cannot come with a ProvisionedThroughput: with pytest.raises(ClientError, match='ValidationException'): create_table(dynamodb, test_table_name(), BillingMode='PAY_PER_REQUEST', ProvisionedThroughput={'ReadCapacityUnits': 10, 'WriteCapacityUnits': 10}) # On the other hand, PROVISIONED requires ProvisionedThroughput: # By the way, ProvisionedThroughput not only needs to appear, it must # have both ReadCapacityUnits and WriteCapacityUnits - but we can't test # this with boto3, because boto3 has its own verification that if # ProvisionedThroughput is given, it must have the correct form. with pytest.raises(ClientError, match='ValidationException'): create_table(dynamodb, test_table_name(), BillingMode='PROVISIONED') # If BillingMode is completely missing, it defaults to PROVISIONED, so # ProvisionedThroughput is required with pytest.raises(ClientError, match='ValidationException'): dynamodb.create_table(TableName=test_table_name(), KeySchema=[{ 'AttributeName': 'p', 'KeyType': 'HASH' }], AttributeDefinitions=[{ 'AttributeName': 'p', 'AttributeType': 'S' }])