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


Python stub.ANY属性代码示例

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


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

示例1: add_response

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def add_response(self, method, service_response, expected_params=None):
        """
        Adds a service response to the response queue. This will be validated
        against the service model to ensure correctness. It should be noted,
        however, that while missing attributes are often considered correct,
        your code may not function properly if you leave them out. Therefore
        you should always fill in every value you see in a typical response for
        your particular request.

        :param method: The name of the client method to stub.
        :type method: str

        :param service_response: A dict response stub. Provided parameters will
            be validated against the service model.
        :type service_response: dict

        :param expected_params: A dictionary of the expected parameters to
            be called for the provided service response. The parameters match
            the names of keyword arguments passed to that client call. If
            any of the parameters differ a ``StubResponseError`` is thrown.
            You can use stub.ANY to indicate a particular parameter to ignore
            in validation. stub.ANY is only valid for top level params.
        """
        self._add_response(method, service_response, expected_params) 
开发者ID:skarlekar,项目名称:faces,代码行数:26,代码来源:stub.py

示例2: test_map_parameter_grouping

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_map_parameter_grouping():
    """
    Test special parameters that have shape of map are recorded
    as a list of keys based on `para_whitelist.json`
    """
    ddb = session.create_client('dynamodb', region_name='us-west-2')
    response = {
        'ResponseMetadata': {
            'RequestId': REQUEST_ID,
            'HTTPStatusCode': 500,
        }
    }

    with Stubber(ddb) as stubber:
        stubber.add_response('batch_write_item', response, {'RequestItems': ANY})
        ddb.batch_write_item(RequestItems={'table1': [{}], 'table2': [{}]})

    subsegment = xray_recorder.current_segment().subsegments[0]
    assert subsegment.fault
    assert subsegment.http['response']['status'] == 500

    aws_meta = subsegment.aws
    assert sorted(aws_meta['table_names']) == ['table1', 'table2'] 
开发者ID:aws,项目名称:aws-xray-sdk-python,代码行数:25,代码来源:test_botocore.py

示例3: test_s3_bucket_exists

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_s3_bucket_exists(self):
        """Test s3 bucket exists."""
        context = Context(config=self.config)
        stubber = Stubber(context.s3_conn)

        stubber.add_response(
            "head_bucket",
            service_response={},
            expected_params={
                "Bucket": ANY,
            }
        )

        with stubber:
            self.assertIsNone(context._s3_bucket_verified)
            self.assertTrue(context.s3_bucket_verified)
            self.assertTrue(context._s3_bucket_verified)
            stubber.assert_no_pending_responses() 
开发者ID:onicagroup,项目名称:runway,代码行数:20,代码来源:test_context.py

示例4: test_s3_bucket_does_not_exist_us_east

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_s3_bucket_does_not_exist_us_east(self):
        """Create S3 bucket when it does not exist."""
        context = Context(config=self.config, region='us-east-1')
        stubber = Stubber(context.s3_conn)

        stubber.add_client_error(
            "head_bucket",
            service_error_code="NoSuchBucket",
            service_message="Not Found",
            http_status_code=404,
        )
        stubber.add_response(
            "create_bucket",
            service_response={},
            expected_params={
                "Bucket": ANY,
            }
        )

        with stubber:
            self.assertIsNone(context._s3_bucket_verified)
            self.assertTrue(context.s3_bucket_verified)
            self.assertTrue(context._s3_bucket_verified)
            stubber.assert_no_pending_responses() 
开发者ID:onicagroup,项目名称:runway,代码行数:26,代码来源:test_context.py

示例5: test_ensure_cfn_bucket_exists

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_ensure_cfn_bucket_exists(self):
        """Test ensure cfn bucket exists."""
        session = get_session("us-east-1")
        provider = Provider(session)
        action = BaseAction(
            context=mock_context("mynamespace"),
            provider_builder=MockProviderBuilder(provider)
        )
        stubber = Stubber(action.s3_conn)
        stubber.add_response(
            "head_bucket",
            service_response={},
            expected_params={
                "Bucket": ANY,
            }
        )
        with stubber:
            action.ensure_cfn_bucket() 
开发者ID:onicagroup,项目名称:runway,代码行数:20,代码来源:test_base.py

示例6: test_ensure_cfn_bucket_does_not_exist_us_east

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_ensure_cfn_bucket_does_not_exist_us_east(self):
        """Test ensure cfn bucket does not exist us east."""
        session = get_session("us-east-1")
        provider = Provider(session)
        action = BaseAction(
            context=mock_context("mynamespace"),
            provider_builder=MockProviderBuilder(provider)
        )
        stubber = Stubber(action.s3_conn)
        stubber.add_client_error(
            "head_bucket",
            service_error_code="NoSuchBucket",
            service_message="Not Found",
            http_status_code=404,
        )
        stubber.add_response(
            "create_bucket",
            service_response={},
            expected_params={
                "Bucket": ANY,
            }
        )
        with stubber:
            action.ensure_cfn_bucket() 
开发者ID:onicagroup,项目名称:runway,代码行数:26,代码来源:test_base.py

示例7: test_ensure_cfn_bucket_exists

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_ensure_cfn_bucket_exists(self):
        session = get_session("us-east-1")
        provider = Provider(session)
        action = BaseAction(
            context=mock_context("mynamespace"),
            provider_builder=MockProviderBuilder(provider)
        )
        stubber = Stubber(action.s3_conn)
        stubber.add_response(
            "head_bucket",
            service_response={},
            expected_params={
                "Bucket": ANY,
            }
        )
        with stubber:
            action.ensure_cfn_bucket() 
开发者ID:cloudtools,项目名称:stacker,代码行数:19,代码来源:test_base.py

示例8: test_ensure_cfn_bucket_doesnt_exist_us_east

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_ensure_cfn_bucket_doesnt_exist_us_east(self):
        session = get_session("us-east-1")
        provider = Provider(session)
        action = BaseAction(
            context=mock_context("mynamespace"),
            provider_builder=MockProviderBuilder(provider)
        )
        stubber = Stubber(action.s3_conn)
        stubber.add_client_error(
            "head_bucket",
            service_error_code="NoSuchBucket",
            service_message="Not Found",
            http_status_code=404,
        )
        stubber.add_response(
            "create_bucket",
            service_response={},
            expected_params={
                "Bucket": ANY,
            }
        )
        with stubber:
            action.ensure_cfn_bucket() 
开发者ID:cloudtools,项目名称:stacker,代码行数:25,代码来源:test_base.py

示例9: test_random_id_can_be_omitted

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_random_id_can_be_omitted(self, stubbed_session):
        stubbed_session.stub('apigateway').get_authorizers(
            restApiId='rest-api-id').returns({
                'items': [{'authorizerUri': self.GOOD_ARN, 'id': 'good'}]})
        source_arn = (
            'arn:aws:execute-api:us-west-2:1:rest-api-id/authorizers/good'
        )
        stubbed_session.stub('lambda').add_permission(
            Action='lambda:InvokeFunction',
            FunctionName='app-dev-name',
            # Autogenerated value here.
            StatementId=stub.ANY,
            Principal='apigateway.amazonaws.com',
            SourceArn=source_arn
        ).returns({})
        stubbed_session.activate_stubs()
        # Note the omission of the random id.
        TypedAWSClient(stubbed_session).add_permission_for_authorizer(
            'rest-api-id', self.FUNCTION_ARN
        )
        stubbed_session.verify_stubs() 
开发者ID:aws,项目名称:chalice,代码行数:23,代码来源:test_awsclient.py

示例10: test_add_permission_for_scheduled_event

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_add_permission_for_scheduled_event(stubbed_session):
    lambda_client = stubbed_session.stub('lambda')
    lambda_client.get_policy(FunctionName='function-arn').returns(
        {'Policy': '{}'})
    lambda_client.add_permission(
        Action='lambda:InvokeFunction',
        FunctionName='function-arn',
        StatementId=stub.ANY,
        Principal='events.amazonaws.com',
        SourceArn='rule-arn'
    ).returns({})

    stubbed_session.activate_stubs()

    awsclient = TypedAWSClient(stubbed_session)
    awsclient.add_permission_for_cloudwatch_event(
        'rule-arn', 'function-arn')

    stubbed_session.verify_stubs() 
开发者ID:aws,项目名称:chalice,代码行数:21,代码来源:test_awsclient.py

示例11: test_add_permission_for_s3_event

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_add_permission_for_s3_event(stubbed_session):
    lambda_client = stubbed_session.stub('lambda')
    lambda_client.get_policy(FunctionName='function-arn').returns(
        {'Policy': '{}'})
    lambda_client.add_permission(
        Action='lambda:InvokeFunction',
        FunctionName='function-arn',
        StatementId=stub.ANY,
        Principal='s3.amazonaws.com',
        SourceArn='arn:aws:s3:::mybucket',
    ).returns({})

    stubbed_session.activate_stubs()

    awsclient = TypedAWSClient(stubbed_session)
    awsclient.add_permission_for_s3_event(
        'mybucket', 'function-arn')
    stubbed_session.verify_stubs() 
开发者ID:aws,项目名称:chalice,代码行数:20,代码来源:test_awsclient.py

示例12: test_mturk_stubber

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_mturk_stubber(session):
    async with session.create_client('mturk', region_name='us-east-1') as client:
        with Stubber(client) as stubber:
            stubber.add_response('list_hits_for_qualification_type',
                                 _mturk_list_hits_response,
                                 {'QualificationTypeId': ANY})

            response = await client.list_hi_ts_for_qualification_type(
                QualificationTypeId='string')
            assert response == _mturk_list_hits_response 
开发者ID:aio-libs,项目名称:aiobotocore,代码行数:12,代码来源:test_mturk.py

示例13: __repr__

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def __repr__(self):
        return '<ANY>' 
开发者ID:skarlekar,项目名称:faces,代码行数:4,代码来源:stub.py

示例14: test_map_parameter_grouping

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_map_parameter_grouping(loop, recorder):
    """
    Test special parameters that have shape of map are recorded
    as a list of keys based on `para_whitelist.json`
    """
    segment = recorder.begin_segment('name')

    response = {
        'ResponseMetadata': {
            'RequestId': '1234',
            'HTTPStatusCode': 500,
        }
    }

    session = aiobotocore.get_session()
    async with session.create_client('dynamodb', region_name='eu-west-2') as client:
        with Stubber(client) as stubber:
            stubber.add_response('batch_write_item', response, {'RequestItems': ANY})
            await client.batch_write_item(RequestItems={'table1': [{}], 'table2': [{}]})

    subsegment = segment.subsegments[0]
    assert subsegment.fault
    assert subsegment.http['response']['status'] == 500

    aws_meta = subsegment.aws
    assert sorted(aws_meta['table_names']) == ['table1', 'table2'] 
开发者ID:aws,项目名称:aws-xray-sdk-python,代码行数:28,代码来源:test_aiobotocore.py

示例15: test_context_missing_not_suppress_exception

# 需要导入模块: from botocore import stub [as 别名]
# 或者: from botocore.stub import ANY [as 别名]
def test_context_missing_not_suppress_exception(loop, recorder):
    xray_recorder.configure(service='test', sampling=False,
                            context=AsyncContext(loop=loop), context_missing='LOG_ERROR')

    session = aiobotocore.get_session()
    async with session.create_client('dynamodb', region_name='eu-west-2') as client:
        with Stubber(client) as stubber:
            stubber.add_client_error('describe_table', expected_params={'TableName': ANY})
            with pytest.raises(ClientError):
                await client.describe_table(TableName='mytable') 
开发者ID:aws,项目名称:aws-xray-sdk-python,代码行数:12,代码来源:test_aiobotocore.py


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