#NEWLINE# @ patch . object ( pypicloud . storage . s3 , 'boto' ) #NEWLINE# def test_create_bucket( self , boto_mock ) : #NEWLINE# #INDENT# " If S3 bucket doesn't exist, create it " #NEWLINE# conn = boto_mock . s3 . connect_to_region ( ) #NEWLINE# boto_mock . exception . S3ResponseError = boto . exception . S3ResponseError #NEWLINE# def raise_not_found( * _ , **__ ) : #NEWLINE# #INDENT# " Raise a 'bucket not found' exception " #NEWLINE# e = boto . exception . S3ResponseError ( 400 , 'missing' ) #NEWLINE# e . error_code = 'NoSuchBucket' #NEWLINE# raise e #NEWLINE# #UNINDENT# conn . get_bucket = raise_not_found #NEWLINE# settings = { #NEWLINE# #INDENT# 'storage.bucket' : 'new_bucket' , #NEWLINE# 'storage.region' : 'us-east-1' , #NEWLINE# #UNINDENT# } #NEWLINE# S3Storage . configure ( raise_not_found ) #NEWLINE# conn . create_bucket . assert_called_with ( 'new_bucket' , location = 'us-east-1' )