#NEWLINE# @ mock_lambda #NEWLINE# @ mock_s3 #NEWLINE# @ freeze_time ( '2015-01-01 00:00:00' ) #NEWLINE# def test_list_create_list_get_delete_list( ) : #NEWLINE# #INDENT# '\n    test `list -> create -> list -> get -> delete -> list` integration\n\n    ' #NEWLINE# s3_conn = boto3 . client ( 's3' , 'us-west-2' ) #NEWLINE# s3_conn . create_bucket ( Bucket = 'test-bucket' ) #NEWLINE# zip_content = get_test_zip_file ( ) #NEWLINE# s3_conn . put_object ( Bucket = 'test-bucket' , Key = 'test.zip' , Body = zip_content ) #NEWLINE# conn = boto3 . client ( 'lambda' , 'us-west-2' ) #NEWLINE# conn . list_functions ( ) [ 'Functions' ] . should . have . length_of ( 0 ) #NEWLINE# conn . create_function ( FunctionName = 'testFunction' , Runtime = 'python2.7' , Role = 'test-iam-role' , Handler = 'lambda_function.handler' , Code = { #NEWLINE# #INDENT# 'S3Bucket' : 'test-bucket' , #NEWLINE# 'S3Key' : 'test.zip' , #NEWLINE# #UNINDENT# } , Description = 'test lambda function' , Timeout = 3 , MemorySize = 128 , Publish = True ) #NEWLINE# expected_function_result = { #NEWLINE# #INDENT# 'Code' : { #NEWLINE# #INDENT# 'Location' : 's3://lambda-functions.aws.amazon.com/test.zip' , #NEWLINE# 'RepositoryType' : 'S3' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'Configuration' : { #NEWLINE# #INDENT# 'CodeSha256' : hashlib . sha256 ( zip_content ) . hexdigest ( ) , #NEWLINE# 'CodeSize' : len ( expected_function_result ) , #NEWLINE# 'Description' : 'test lambda function' , #NEWLINE# 'FunctionArn' : 'arn:aws:lambda:123456789012:function:testFunction' , #NEWLINE# 'FunctionName' : 'testFunction' , #NEWLINE# 'Handler' : 'lambda_function.handler' , #NEWLINE# 'LastModified' : '2015-01-01 00:00:00' , #NEWLINE# 'MemorySize' : 128 , #NEWLINE# 'Role' : 'test-iam-role' , #NEWLINE# 'Runtime' : 'python2.7' , #NEWLINE# 'Timeout' : 3 , #NEWLINE# 'Version' : '$LATEST' , #NEWLINE# 'VpcConfig' : { #NEWLINE# #INDENT# 'SecurityGroupIds' : [ ] , #NEWLINE# 'SubnetIds' : [ ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'ResponseMetadata' : { #NEWLINE# #INDENT# 'HTTPStatusCode' : 200 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# conn . list_functions ( ) [ 'Functions' ] . should . equal ( [ expected_function_result [ 'Configuration' ] ] ) #NEWLINE# conn . get_function ( FunctionName = 'testFunction' ) . should . equal ( expected_function_result ) #NEWLINE# conn . delete_function ( FunctionName = 'testFunction' ) #NEWLINE# conn . list_functions ( ) [ 'Functions' ] . should . have . length_of ( 0 )