Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@mock_dynamodb2
def test_dynamo_get_or_create():
get_or_create_tracker_store(DynamoTrackerStore(domain))
def _handle_dynamodb_table(resources):
from moto import mock_dynamodb2
dynamodb = mock_dynamodb2()
def before():
dynamodb.start()
for resource_definition in resources:
boto3.resource("dynamodb").create_table(
**_get_property(
resource_definition["Properties"],
(
"TableName",
"AttributeDefinitions",
"KeySchema",
"LocalSecondaryIndexes",
"GlobalSecondaryIndexes",
"BillingMode",
"ProvisionedThroughput",
@mock_dynamodb2
@mock_iam
@mock_sts
def test_clean_snapshots_tagged_timeout(mocker):
"""Test that we _DONT_ clean anything if runtime > 4 minutes"""
# default settings
region = 'us-east-1'
mocks.create_dynamodb(region)
ctx = utils.MockContext()
ctx.set_remaining_time_in_millis(5) # 5 millis remaining
# create an instance and record the id
instance_id = mocks.create_instances(region, count=1)[0]
# setup the min # snaps for the instance
config_data = {
"match": {"instance-id": instance_id},
def _set_up_app(self):
self._ddb = mock_dynamodb2()
self._ddb.start()
from application import configure_logging
configure_logging()
setting_overrides = {
'SQLALCHEMY_DATABASE_URI': 'sqlite://',
'EQ_DYNAMODB_ENDPOINT': None
}
self._application = create_app(setting_overrides)
self._key_store = KeyStore({
'keys': {
EQ_USER_AUTHENTICATION_RRM_PRIVATE_KEY_KID: {
'purpose': KEY_PURPOSE_AUTHENTICATION,
@mock_dynamodb2
def test_scan_filter3():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
# Create the DynamoDB table.
client.create_table(
TableName="test1",
AttributeDefinitions=[
{"AttributeName": "client", "AttributeType": "S"},
{"AttributeName": "app", "AttributeType": "N"},
],
KeySchema=[
{"AttributeName": "client", "KeyType": "HASH"},
{"AttributeName": "app", "KeyType": "RANGE"},
],
ProvisionedThroughput={"ReadCapacityUnits": 123, "WriteCapacityUnits": 123},
@mock_dynamodb2
def test_basic_projection_expressions():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
# Create the DynamoDB table.
table = dynamodb.create_table(
TableName="users",
KeySchema=[
{"AttributeName": "forum_name", "KeyType": "HASH"},
{"AttributeName": "subject", "KeyType": "RANGE"},
],
AttributeDefinitions=[
{"AttributeName": "forum_name", "AttributeType": "S"},
{"AttributeName": "subject", "AttributeType": "S"},
],
ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
)
@mock_dynamodb2
def test_get_item_returns_consumed_capacity():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
# Create the DynamoDB table.
table = dynamodb.create_table(
TableName="users",
KeySchema=[
{"AttributeName": "forum_name", "KeyType": "HASH"},
{"AttributeName": "subject", "KeyType": "RANGE"},
],
AttributeDefinitions=[
{"AttributeName": "forum_name", "AttributeType": "S"},
{"AttributeName": "subject", "AttributeType": "S"},
],
ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
)
@mock_dynamodb2
def test_basic_projection_expressions_using_scan_with_attr_expression_names():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
# Create the DynamoDB table.
table = dynamodb.create_table(
TableName="users",
KeySchema=[
{"AttributeName": "forum_name", "KeyType": "HASH"},
{"AttributeName": "subject", "KeyType": "RANGE"},
],
AttributeDefinitions=[
{"AttributeName": "forum_name", "AttributeType": "S"},
{"AttributeName": "subject", "AttributeType": "S"},
],
ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
)
@mock_dynamodb2
def test_condition_expressions():
client = boto3.client("dynamodb", region_name="us-east-1")
# Create the DynamoDB table.
client.create_table(
TableName="test1",
AttributeDefinitions=[
{"AttributeName": "client", "AttributeType": "S"},
{"AttributeName": "app", "AttributeType": "S"},
],
KeySchema=[
{"AttributeName": "client", "KeyType": "HASH"},
{"AttributeName": "app", "KeyType": "RANGE"},
],
ProvisionedThroughput={"ReadCapacityUnits": 123, "WriteCapacityUnits": 123},
)
@mock_dynamodb2
@mock_iam
@mock_sts
def test_clean_tagged_snapshots_ignore_instance(mocker):
"""Test for method of the same name."""
# default settings
region = 'us-east-1'
mocks.create_dynamodb(region)
# create an instance and record the id
instance_id = mocks.create_instances(region, count=1)[0]
ctx = utils.MockContext()
# setup the min # snaps for the instance
config_data = {
"match": {"instance-id": instance_id},
"snapshot": {