本文整理汇总了Python中chalice.awsclient.TypedAWSClient.update_function方法的典型用法代码示例。如果您正苦于以下问题:Python TypedAWSClient.update_function方法的具体用法?Python TypedAWSClient.update_function怎么用?Python TypedAWSClient.update_function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chalice.awsclient.TypedAWSClient
的用法示例。
在下文中一共展示了TypedAWSClient.update_function方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_function_is_retried_and_succeeds
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_update_function_is_retried_and_succeeds(self, stubbed_session):
stubbed_session.stub('lambda').update_function_code(
FunctionName='name', ZipFile=b'foo').returns(
{'FunctionArn': 'arn'})
update_config_kwargs = {
'FunctionName': 'name',
'Role': 'role-arn'
}
# This should fail two times with retryable exceptions and
# then succeed to update the lambda function.
stubbed_session.stub('lambda').update_function_configuration(
**update_config_kwargs).raises_error(
error_code='InvalidParameterValueException',
message=('The role defined for the function cannot '
'be assumed by Lambda.'))
stubbed_session.stub('lambda').update_function_configuration(
**update_config_kwargs).raises_error(
error_code='InvalidParameterValueException',
message=('The role defined for the function cannot '
'be assumed by Lambda.'))
stubbed_session.stub('lambda').update_function_configuration(
**update_config_kwargs).returns({})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
awsclient.update_function('name', b'foo', role_arn='role-arn')
stubbed_session.verify_stubs()
示例2: test_always_update_function_code
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_always_update_function_code(self, stubbed_session):
lambda_client = stubbed_session.stub('lambda')
lambda_client.update_function_code(
FunctionName='name', ZipFile=b'foo').returns({})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session)
awsclient.update_function('name', b'foo')
stubbed_session.verify_stubs()
示例3: test_raises_large_deployment_error_for_too_large_unzip
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_raises_large_deployment_error_for_too_large_unzip(
self, stubbed_session):
stubbed_session.stub('lambda').update_function_code(
FunctionName='name', ZipFile=b'foo').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.update_function('name', b'foo')
stubbed_session.verify_stubs()
示例4: test_raises_large_deployment_error_request_entity_to_large
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_raises_large_deployment_error_request_entity_to_large(
self, stubbed_session):
stubbed_session.stub('lambda').update_function_code(
FunctionName='name', ZipFile=b'foo').raises_error(
error_code='RequestEntityTooLargeException',
message='')
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
with pytest.raises(DeploymentPackageTooLargeError):
awsclient.update_function('name', b'foo')
stubbed_session.verify_stubs()
示例5: test_update_function_code_with_memory
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_update_function_code_with_memory(self, stubbed_session):
lambda_client = stubbed_session.stub('lambda')
lambda_client.update_function_code(
FunctionName='name', ZipFile=b'foo').returns({})
lambda_client.update_function_configuration(
FunctionName='name',
MemorySize=256).returns({})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session)
awsclient.update_function('name', b'foo', memory_size=256)
stubbed_session.verify_stubs()
示例6: test_update_function_code_with_timeout
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_update_function_code_with_timeout(self, stubbed_session):
lambda_client = stubbed_session.stub('lambda')
lambda_client.update_function_code(
FunctionName='name', ZipFile=b'foo').returns({})
lambda_client.update_function_configuration(
FunctionName='name',
Timeout=240).returns({})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session)
awsclient.update_function('name', b'foo', timeout=240)
stubbed_session.verify_stubs()
示例7: test_update_function_code_with_environment_vars
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_update_function_code_with_environment_vars(self, stubbed_session):
lambda_client = stubbed_session.stub('lambda')
lambda_client.update_function_code(
FunctionName='name', ZipFile=b'foo').returns({})
lambda_client.update_function_configuration(
FunctionName='name',
Environment={'Variables': {"FOO": "BAR"}}).returns({})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session)
awsclient.update_function(
'name', b'foo', {"FOO": "BAR"})
stubbed_session.verify_stubs()
示例8: test_no_raise_large_deployment_error_when_small_deployment_size
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_no_raise_large_deployment_error_when_small_deployment_size(
self, stubbed_session):
stubbed_session.stub('lambda').update_function_code(
FunctionName='name', ZipFile=b'foo').raises_error(
error=RequestsConnectionError())
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
with pytest.raises(LambdaClientError) as excinfo:
awsclient.update_function('name', b'foo')
stubbed_session.verify_stubs()
assert not isinstance(excinfo.value, DeploymentPackageTooLargeError)
assert isinstance(
excinfo.value.original_error, RequestsConnectionError)
示例9: test_update_function_with_no_tag_updates_needed
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_update_function_with_no_tag_updates_needed(self, stubbed_session):
function_arn = 'arn'
lambda_client = stubbed_session.stub('lambda')
lambda_client.update_function_code(
FunctionName='name', ZipFile=b'foo').returns(
{'FunctionArn': function_arn})
lambda_client.list_tags(
Resource=function_arn).returns({'Tags': {'MyKey': 'SameValue'}})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session)
awsclient.update_function('name', b'foo', tags={'MyKey': 'SameValue'})
stubbed_session.verify_stubs()
示例10: test_update_function_with_iam_role
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_update_function_with_iam_role(self, stubbed_session):
function_arn = 'arn'
lambda_client = stubbed_session.stub('lambda')
lambda_client.update_function_code(
FunctionName='name', ZipFile=b'foo').returns(
{'FunctionArn': function_arn})
lambda_client.update_function_configuration(
FunctionName='name',
Role='role-arn').returns({})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session)
awsclient.update_function('name', b'foo', role_arn='role-arn')
stubbed_session.verify_stubs()
示例11: test_raises_large_deployment_error_for_connection_error
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_raises_large_deployment_error_for_connection_error(
self, stubbed_session):
too_large_content = b'a' * 60 * (1024 ** 2)
stubbed_session.stub('lambda').update_function_code(
FunctionName='name', ZipFile=too_large_content).raises_error(
error=RequestsConnectionError())
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
with pytest.raises(DeploymentPackageTooLargeError) as excinfo:
awsclient.update_function('name', too_large_content)
stubbed_session.verify_stubs()
assert excinfo.value.context.function_name == 'name'
assert (
excinfo.value.context.client_method_name == 'update_function_code')
assert excinfo.value.context.deployment_size == 60 * (1024 ** 2)
示例12: test_update_function_with_removing_tags
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_update_function_with_removing_tags(self, stubbed_session):
function_arn = 'arn'
lambda_client = stubbed_session.stub('lambda')
lambda_client.update_function_code(
FunctionName='name', ZipFile=b'foo').returns(
{'FunctionArn': function_arn})
lambda_client.list_tags(
Resource=function_arn).returns(
{'Tags': {'KeyToRemove': 'Value'}})
lambda_client.untag_resource(
Resource=function_arn, TagKeys=['KeyToRemove']).returns({})
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session)
awsclient.update_function('name', b'foo', tags={})
stubbed_session.verify_stubs()
示例13: test_update_function_fails_after_max_retries
# 需要导入模块: from chalice.awsclient import TypedAWSClient [as 别名]
# 或者: from chalice.awsclient.TypedAWSClient import update_function [as 别名]
def test_update_function_fails_after_max_retries(self, stubbed_session):
stubbed_session.stub('lambda').update_function_code(
FunctionName='name', ZipFile=b'foo').returns(
{'FunctionArn': 'arn'})
update_config_kwargs = {
'FunctionName': 'name',
'Role': 'role-arn'
}
for _ in range(TypedAWSClient.LAMBDA_CREATE_ATTEMPTS):
stubbed_session.stub('lambda').update_function_configuration(
**update_config_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.update_function('name', b'foo', role_arn='role-arn')
stubbed_session.verify_stubs()