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


Python TypedAWSClient.create_function方法代码示例

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


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

示例1: test_create_function_is_retried_and_succeeds

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_create_function_is_retried_and_succeeds(self, stubbed_session):
     kwargs = {
         'FunctionName': 'name',
         'Runtime': 'python2.7',
         'Code': {'ZipFile': b'foo'},
         'Handler': 'app.app',
         'Role': 'myarn',
     }
     stubbed_session.stub('lambda').create_function(
         **kwargs).raises_error(
         error_code='InvalidParameterValueException',
         message=('The role defined for the function cannot '
                  'be assumed by Lambda.'))
     stubbed_session.stub('lambda').create_function(
         **kwargs).raises_error(
         error_code='InvalidParameterValueException',
         message=('The role defined for the function cannot '
                  'be assumed by Lambda.'))
     stubbed_session.stub('lambda').create_function(
         **kwargs).returns({'FunctionArn': 'arn:12345:name'})
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
     assert awsclient.create_function(
         'name', 'myarn', b'foo',
         'python2.7', 'app.app') == 'arn:12345:name'
     stubbed_session.verify_stubs()
开发者ID:jamesls,项目名称:chalice,代码行数:28,代码来源:test_awsclient.py

示例2: test_create_function_propagates_unknown_error

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_create_function_propagates_unknown_error(self, stubbed_session):
     kwargs = {
         'FunctionName': 'name',
         'Runtime': 'python2.7',
         'Code': {'ZipFile': b'foo'},
         'Handler': 'app.app',
         'Role': 'myarn',
         'Timeout': 60,
     }
     stubbed_session.stub('lambda').create_function(
         **kwargs).raises_error(
         error_code='UnknownException', message='')
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
     with pytest.raises(botocore.exceptions.ClientError):
         awsclient.create_function('name', 'myarn', b'foo')
     stubbed_session.verify_stubs()
开发者ID:shunsuke-aikawa,项目名称:chalice,代码行数:19,代码来源:test_awsclient.py

示例3: test_raises_large_deployment_error_for_too_large_unzip

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_raises_large_deployment_error_for_too_large_unzip(
         self, stubbed_session):
     kwargs = {
         'FunctionName': 'name',
         'Runtime': 'python2.7',
         'Code': {'ZipFile': b'foo'},
         'Handler': 'app.app',
         'Role': 'myarn',
     }
     stubbed_session.stub('lambda').create_function(
         **kwargs).raises_error(
             error_code='InvalidParameterValueException',
             message='Unzipped size must be smaller than ...')
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
     with pytest.raises(DeploymentPackageTooLargeError):
         awsclient.create_function('name', 'myarn', b'foo', 'python2.7',
                                   'app.app')
     stubbed_session.verify_stubs()
开发者ID:jamesls,项目名称:chalice,代码行数:21,代码来源:test_awsclient.py

示例4: test_raises_large_deployment_error_request_entity_to_large

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_raises_large_deployment_error_request_entity_to_large(
         self, stubbed_session):
     kwargs = {
         'FunctionName': 'name',
         'Runtime': 'python2.7',
         'Code': {'ZipFile': b'foo'},
         'Handler': 'app.app',
         'Role': 'myarn',
     }
     stubbed_session.stub('lambda').create_function(
         **kwargs).raises_error(
             error_code='RequestEntityTooLargeException',
             message='')
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
     with pytest.raises(DeploymentPackageTooLargeError):
         awsclient.create_function('name', 'myarn', b'foo', 'python2.7',
                                   'app.app')
     stubbed_session.verify_stubs()
开发者ID:jamesls,项目名称:chalice,代码行数:21,代码来源:test_awsclient.py

示例5: test_create_function_fails_after_max_retries

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
    def test_create_function_fails_after_max_retries(self, stubbed_session):
        kwargs = {
            'FunctionName': 'name',
            'Runtime': 'python2.7',
            'Code': {'ZipFile': b'foo'},
            'Handler': 'app.app',
            'Role': 'myarn',
            'Timeout': 60,
        }
        for _ in range(TypedAWSClient.LAMBDA_CREATE_ATTEMPTS):
            stubbed_session.stub('lambda').create_function(
                **kwargs).raises_error(
                error_code='InvalidParameterValueException', message='')

        stubbed_session.activate_stubs()
        awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
        with pytest.raises(botocore.exceptions.ClientError):
            awsclient.create_function('name', 'myarn', b'foo')
        stubbed_session.verify_stubs()
开发者ID:shunsuke-aikawa,项目名称:chalice,代码行数:21,代码来源:test_awsclient.py

示例6: test_no_raise_large_deployment_error_when_small_deployment_size

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
    def test_no_raise_large_deployment_error_when_small_deployment_size(
            self, stubbed_session):
        kwargs = {
            'FunctionName': 'name',
            'Runtime': 'python2.7',
            'Code': {'ZipFile': b'foo'},
            'Handler': 'app.app',
            'Role': 'myarn',
        }

        stubbed_session.stub('lambda').create_function(
            **kwargs).raises_error(error=RequestsConnectionError())
        stubbed_session.activate_stubs()
        awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
        with pytest.raises(LambdaClientError) as excinfo:
            awsclient.create_function('name', 'myarn', b'foo',
                                      'python2.7', 'app.app')
        stubbed_session.verify_stubs()
        assert not isinstance(excinfo.value, DeploymentPackageTooLargeError)
        assert isinstance(
            excinfo.value.original_error, RequestsConnectionError)
开发者ID:jamesls,项目名称:chalice,代码行数:23,代码来源:test_awsclient.py

示例7: test_raises_large_deployment_error_for_connection_error

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
    def test_raises_large_deployment_error_for_connection_error(
            self, stubbed_session):
        too_large_content = b'a' * 60 * (1024 ** 2)
        kwargs = {
            'FunctionName': 'name',
            'Runtime': 'python2.7',
            'Code': {'ZipFile': too_large_content},
            'Handler': 'app.app',
            'Role': 'myarn',
        }

        stubbed_session.stub('lambda').create_function(
            **kwargs).raises_error(error=RequestsConnectionError())
        stubbed_session.activate_stubs()
        awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
        with pytest.raises(DeploymentPackageTooLargeError) as excinfo:
            awsclient.create_function('name', 'myarn', too_large_content,
                                      'python2.7', 'app.app')
        stubbed_session.verify_stubs()
        assert excinfo.value.context.function_name == 'name'
        assert excinfo.value.context.client_method_name == 'create_function'
        assert excinfo.value.context.deployment_size == 60 * (1024 ** 2)
开发者ID:jamesls,项目名称:chalice,代码行数:24,代码来源:test_awsclient.py

示例8: test_can_pass_python_runtime

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_can_pass_python_runtime(self, stubbed_session):
     stubbed_session.stub('lambda').create_function(
         FunctionName='name',
         Runtime='python3.6',
         Code={'ZipFile': b'foo'},
         Handler='app.app',
         Role='myarn',
     ).returns({'FunctionArn': 'arn:12345:name'})
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session)
     assert awsclient.create_function(
         'name', 'myarn', b'foo',
         runtime='python3.6', handler='app.app') == 'arn:12345:name'
     stubbed_session.verify_stubs()
开发者ID:jamesls,项目名称:chalice,代码行数:16,代码来源:test_awsclient.py

示例9: test_create_function_succeeds_first_try

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_create_function_succeeds_first_try(self, stubbed_session):
     stubbed_session.stub('lambda').create_function(
         FunctionName='name',
         Runtime='python2.7',
         Code={'ZipFile': b'foo'},
         Handler='app.app',
         Role='myarn',
         Timeout=60,
     ).returns({'FunctionArn': 'arn:12345:name'})
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session)
     assert awsclient.create_function(
         'name', 'myarn', b'foo') == 'arn:12345:name'
     stubbed_session.verify_stubs()
开发者ID:shunsuke-aikawa,项目名称:chalice,代码行数:16,代码来源:test_awsclient.py

示例10: test_create_function_fails_after_max_retries

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
    def test_create_function_fails_after_max_retries(self, stubbed_session):
        kwargs = {
            'FunctionName': 'name',
            'Runtime': 'python2.7',
            'Code': {'ZipFile': b'foo'},
            'Handler': 'app.app',
            'Role': 'myarn',
        }
        for _ in range(TypedAWSClient.LAMBDA_CREATE_ATTEMPTS):
            stubbed_session.stub('lambda').create_function(
                **kwargs).raises_error(
                error_code='InvalidParameterValueException',
                message=('The role defined for the function cannot '
                         'be assumed by Lambda.')
                )

        stubbed_session.activate_stubs()
        awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
        with pytest.raises(LambdaClientError) as excinfo:
            awsclient.create_function('name', 'myarn', b'foo', 'python2.7',
                                      'app.app')
        assert isinstance(
            excinfo.value.original_error, botocore.exceptions.ClientError)
        stubbed_session.verify_stubs()
开发者ID:jamesls,项目名称:chalice,代码行数:26,代码来源:test_awsclient.py

示例11: test_create_function_with_memory_size

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_create_function_with_memory_size(self, stubbed_session):
     stubbed_session.stub('lambda').create_function(
         FunctionName='name',
         Runtime='python2.7',
         Code={'ZipFile': b'foo'},
         Handler='app.app',
         Role='myarn',
         MemorySize=256
     ).returns({'FunctionArn': 'arn:12345:name'})
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session)
     assert awsclient.create_function(
         'name', 'myarn', b'foo', 'python2.7', 'app.app',
         memory_size=256) == 'arn:12345:name'
     stubbed_session.verify_stubs()
开发者ID:jamesls,项目名称:chalice,代码行数:17,代码来源:test_awsclient.py

示例12: test_create_function_with_environment_variables

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_create_function_with_environment_variables(self, stubbed_session):
     stubbed_session.stub('lambda').create_function(
         FunctionName='name',
         Runtime='python2.7',
         Code={'ZipFile': b'foo'},
         Handler='app.app',
         Role='myarn',
         Environment={'Variables': {'FOO': 'BAR'}}
     ).returns({'FunctionArn': 'arn:12345:name'})
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session)
     assert awsclient.create_function(
         'name', 'myarn', b'foo', 'python2.7',
         handler='app.app',
         environment_variables={'FOO': 'BAR'}) == 'arn:12345:name'
     stubbed_session.verify_stubs()
开发者ID:jamesls,项目名称:chalice,代码行数:18,代码来源:test_awsclient.py

示例13: test_can_provide_tags

# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import create_function [as 别名]
 def test_can_provide_tags(self, stubbed_session):
     stubbed_session.stub('lambda').create_function(
         FunctionName='name',
         Runtime='python2.7',
         Code={'ZipFile': b'foo'},
         Handler='app.app',
         Role='myarn',
         Tags={'key': 'value'},
     ).returns({'FunctionArn': 'arn:12345:name'})
     stubbed_session.activate_stubs()
     awsclient = TypedAWSClient(stubbed_session)
     assert awsclient.create_function(
         function_name='name',
         role_arn='myarn',
         zip_contents=b'foo',
         runtime='python2.7',
         tags={'key': 'value'},
         handler='app.app') == 'arn:12345:name'
     stubbed_session.verify_stubs()
开发者ID:jamesls,项目名称:chalice,代码行数:21,代码来源:test_awsclient.py


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