当前位置: 首页>>代码示例>>Python>>正文


Python moto.mock_dynamodb2方法代码示例

本文整理汇总了Python中moto.mock_dynamodb2方法的典型用法代码示例。如果您正苦于以下问题:Python moto.mock_dynamodb2方法的具体用法?Python moto.mock_dynamodb2怎么用?Python moto.mock_dynamodb2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moto的用法示例。


在下文中一共展示了moto.mock_dynamodb2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def setup(self):
        """LookupTables - Setup S3 bucket mocking"""
        self.config = load_config('tests/unit/conf')

        self.s3_mock = mock_s3()
        self.s3_mock.start()

        self.dynamodb_mock = mock_dynamodb2()
        self.dynamodb_mock.start()

        self._put_mock_data()

        self._lookup_tables = LookupTables.get_instance(
            config=self.config,
            reset=True
        ) 
开发者ID:airbnb,项目名称:streamalert,代码行数:18,代码来源:test_core.py

示例2: setup

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def setup(self):
        """LookupTables - Setup S3 bucket mocking"""
        self.config = load_config('tests/unit/conf')
        self._dynamodb_mock = mock_dynamodb2()
        self._dynamodb_mock.start()

        self._driver = construct_persistence_driver(
            self.config['lookup_tables']['tables']['dinosaur']
        )
        self._bad_driver = construct_persistence_driver(
            {
                'driver': 'dynamodb',
                'table': 'table???',
                'partition_key': '??',
                'value_key': '?zlaerf',
            }
        )

        self._put_mock_tables() 
开发者ID:airbnb,项目名称:streamalert,代码行数:21,代码来源:test_driver_dynamodb.py

示例3: setup

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def setup(self):
        """Alert Table - Create mock table and alerts"""
        # pylint: disable=attribute-defined-outside-init
        self.dynamo_mock = mock_dynamodb2()
        self.dynamo_mock.start()

        setup_mock_alerts_table(_ALERTS_TABLE)
        self.alert_table = alert_table.AlertTable(_ALERTS_TABLE)

        self.alerts = [
            alert_module.Alert(
                'even' if i % 2 == 0 else 'odd',
                {'key1': 'value1', 'key2': 'value2'},
                {'aws-firehose:alerts', 'aws-s3:test-bucket', 'slack:test-channel'},
            )
            for i in range(3)
        ]
        self.alert_table.add_alerts(self.alerts) 
开发者ID:airbnb,项目名称:streamalert,代码行数:20,代码来源:test_alert_table.py

示例4: example_table

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def example_table():
    mock_dynamodb2().start(reset=False)
    ddb = boto3.client("dynamodb", region_name=TEST_REGION_NAME)
    ddb.create_table(
        TableName=TEST_TABLE_NAME,
        KeySchema=[
            {"AttributeName": "partition_attribute", "KeyType": "HASH"},
            {"AttributeName": "sort_attribute", "KeyType": "RANGE"},
        ],
        AttributeDefinitions=[
            {"AttributeName": name, "AttributeType": value["type"]} for name, value in TEST_INDEX.items()
        ],
        ProvisionedThroughput={"ReadCapacityUnits": 100, "WriteCapacityUnits": 100},
    )
    yield
    ddb.delete_table(TableName=TEST_TABLE_NAME)
    mock_dynamodb2().stop() 
开发者ID:aws,项目名称:aws-dynamodb-encryption-python,代码行数:19,代码来源:functional_test_utils.py

示例5: setup

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def setup(self):
        with moto.mock_cloudformation(), moto.mock_dynamodb2(), moto.mock_sts():
            setup = lambda_handler.Setup(logging)
            yield setup 
开发者ID:servian,项目名称:aws-auto-remediate,代码行数:6,代码来源:test_setup.py

示例6: start_mock

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def start_mock(self):
        self.mock_s3 = mock_s3()
        self.mock_ddb = mock_dynamodb2()
        self.mock_s3.start()
        self.mock_ddb.start()

        self.bucket = csv_s3
        self.s3 = boto3.client('s3')
        self.s3.create_bucket(Bucket=self.bucket) 
开发者ID:awskrug,项目名称:handson-labs-2018,代码行数:11,代码来源:tests.py

示例7: setup

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def setup(self):
        """Rule Table - Create mock table and rules"""
        # pylint: disable=attribute-defined-outside-init
        self.dynamo_mock = mock_dynamodb2()
        self.dynamo_mock.start()
        setup_mock_rules_table(_RULES_TABLE)
        self.rule_table = rule_table.RuleTable(_RULES_TABLE) 
开发者ID:airbnb,项目名称:streamalert,代码行数:9,代码来源:test_rule_table.py

示例8: setup

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def setup(self):
        """RulePromoter - Setup"""
        # pylint: disable=attribute-defined-outside-init
        self.dynamo_mock = mock_dynamodb2()
        self.dynamo_mock.start()
        with patch('streamalert.rule_promotion.promoter.load_config') as config_mock, \
             patch('streamalert.rule_promotion.promoter.StatsPublisher', Mock()), \
             patch('boto3.client', _mock_boto), \
             patch.dict(os.environ, {'AWS_DEFAULT_REGION': 'us-east-1'}):
            setup_mock_rules_table(_RULES_TABLE)
            config_mock.return_value = config.load_config('tests/unit/conf/')
            self.promoter = RulePromoter()
            self._add_fake_stats() 
开发者ID:airbnb,项目名称:streamalert,代码行数:15,代码来源:test_promoter.py

示例9: dynamodb

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def dynamodb(aws_credentials):
    with mock_dynamodb2():
        yield boto3.resource('dynamodb', region_name='us-east-1') 
开发者ID:Netflix-Skunkworks,项目名称:swag-client,代码行数:5,代码来源:conftest.py

示例10: test_class

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def test_class(self):
        with moto.mock_dynamodb2():
            whitelist = {}
            settings = {
                "general": {"dry_run": False},
                "services": {"dynamodb": {"tables": {"clean": True, "ttl": -1}}},
            }
            resource_tree = {"AWS": {}}

            test_class = dynamodb_cleanup.DynamoDBCleanup(
                logging, whitelist, settings, resource_tree, "ap-southeast-2"
            )
            yield test_class 
开发者ID:servian,项目名称:aws-auto-cleanup,代码行数:15,代码来源:test_dynamodb.py

示例11: mock_db

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def mock_db(request):
    """We never want to use the real dynamodb."""
    mock = mock_dynamodb2()
    mock.start()
    request.addfinalizer(mock.stop) 
开发者ID:clearcare,项目名称:cc_dynamodb3,代码行数:7,代码来源:conftest.py

示例12: table_with_local_secondary_indexes

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def table_with_local_secondary_indexes():
    mock_dynamodb2().start(reset=False)
    ddb = boto3.client("dynamodb", region_name=TEST_REGION_NAME)
    ddb.create_table(
        TableName=TEST_TABLE_NAME,
        KeySchema=[
            {"AttributeName": "partition_attribute", "KeyType": "HASH"},
            {"AttributeName": "sort_attribute", "KeyType": "RANGE"},
        ],
        LocalSecondaryIndexes=[
            {
                "IndexName": "lsi-1",
                "KeySchema": [{"AttributeName": "secondary_index_1", "KeyType": "HASH"}],
                "Projection": {"ProjectionType": "ALL"},
            },
            {
                "IndexName": "lsi-2",
                "KeySchema": [{"AttributeName": "secondary_index_2", "KeyType": "HASH"}],
                "Projection": {"ProjectionType": "ALL"},
            },
        ],
        AttributeDefinitions=[
            {"AttributeName": name, "AttributeType": value["type"]}
            for name, value in list(TEST_INDEX.items()) + list(SECONDARY_INDEX.items())
        ],
        ProvisionedThroughput={"ReadCapacityUnits": 100, "WriteCapacityUnits": 100},
    )
    yield
    ddb.delete_table(TableName=TEST_TABLE_NAME)
    mock_dynamodb2().stop() 
开发者ID:aws,项目名称:aws-dynamodb-encryption-python,代码行数:32,代码来源:functional_test_utils.py

示例13: table_with_global_secondary_indexes

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def table_with_global_secondary_indexes():
    mock_dynamodb2().start(reset=False)
    ddb = boto3.client("dynamodb", region_name=TEST_REGION_NAME)
    ddb.create_table(
        TableName=TEST_TABLE_NAME,
        KeySchema=[
            {"AttributeName": "partition_attribute", "KeyType": "HASH"},
            {"AttributeName": "sort_attribute", "KeyType": "RANGE"},
        ],
        GlobalSecondaryIndexes=[
            {
                "IndexName": "gsi-1",
                "KeySchema": [{"AttributeName": "secondary_index_1", "KeyType": "HASH"}],
                "Projection": {"ProjectionType": "ALL"},
                "ProvisionedThroughput": {"ReadCapacityUnits": 100, "WriteCapacityUnits": 100},
            },
            {
                "IndexName": "gsi-2",
                "KeySchema": [{"AttributeName": "secondary_index_2", "KeyType": "HASH"}],
                "Projection": {"ProjectionType": "ALL"},
                "ProvisionedThroughput": {"ReadCapacityUnits": 100, "WriteCapacityUnits": 100},
            },
        ],
        AttributeDefinitions=[
            {"AttributeName": name, "AttributeType": value["type"]}
            for name, value in list(TEST_INDEX.items()) + list(SECONDARY_INDEX.items())
        ],
        ProvisionedThroughput={"ReadCapacityUnits": 100, "WriteCapacityUnits": 100},
    )
    yield
    ddb.delete_table(TableName=TEST_TABLE_NAME)
    mock_dynamodb2().stop() 
开发者ID:aws,项目名称:aws-dynamodb-encryption-python,代码行数:34,代码来源:functional_test_utils.py

示例14: mock_metastore

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def mock_metastore():
    with mock_dynamodb2():
        metastore, table_name = build_metastore()
        yield metastore
        delete_metastore(table_name) 
开发者ID:aws,项目名称:aws-dynamodb-encryption-python,代码行数:7,代码来源:functional_test_utils.py

示例15: dynamodb_mock

# 需要导入模块: import moto [as 别名]
# 或者: from moto import mock_dynamodb2 [as 别名]
def dynamodb_mock():
    import moto
    with moto.mock_dynamodb2():
        dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
        create_users_table(dynamodb)
        yield dynamodb 
开发者ID:uber-common,项目名称:opentracing-python-instrumentation,代码行数:8,代码来源:test_boto3.py


注:本文中的moto.mock_dynamodb2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。