#NEWLINE# def prepare_mock_wb_response( node = None , provider = 'github' , files = None , folder = True , path = '/' , method = httpretty . GET , status_code = 200 ) : #NEWLINE# #INDENT# 'Prepare a mock Waterbutler response with httpretty.\n\n    :param Node node: Target node.\n    :param str provider: Addon provider\n    :param list files: Optional list of files. You can specify partial data; missing values\n        will have defaults.\n    :param folder: True if mocking out a folder response, False if a file response.\n    :param path: Waterbutler path, passed to waterbutler_api_url_for.\n    :param str method: HTTP method.\n    :param int status_code: HTTP status.\n    ' #NEWLINE# node = node #NEWLINE# files = ( files or [ ] ) #NEWLINE# wb_url = waterbutler_api_url_for ( node . _id , provider = provider , path = node , meta = True ) #NEWLINE# default_file = { #NEWLINE# #INDENT# 'contentType' : None , #NEWLINE# 'extra' : { #NEWLINE# #INDENT# 'downloads' : 0 , #NEWLINE# 'version' : 1 , #NEWLINE# #UNINDENT# } , #NEWLINE# 'kind' : 'file' , #NEWLINE# 'modified' : None , #NEWLINE# 'name' : 'NewFile' , #NEWLINE# 'path' : '/NewFile' , #NEWLINE# 'provider' : provider , #NEWLINE# 'size' : None , #NEWLINE# 'materialized' : '/' , #NEWLINE# #UNINDENT# } #NEWLINE# if len ( files ) : #NEWLINE# #INDENT# data = [ dict ( default_file , ** each ) for each in files ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = [ default_file ] #NEWLINE# #UNINDENT# jsonapi_data = [ ] #NEWLINE# for datum in data : #NEWLINE# #INDENT# jsonapi_data . append ( { #NEWLINE# #INDENT# 'attributes' : datum , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( not folder ) : #NEWLINE# #INDENT# jsonapi_data = jsonapi_data [ 0 ] #NEWLINE# #UNINDENT# body = json . dumps ( { #NEWLINE# #INDENT# 'data' : jsonapi_data , #NEWLINE# #UNINDENT# } ) #NEWLINE# httpretty . register_uri ( method , wb_url , body = body , status = status_code , content_type = 'application/json' )