#NEWLINE# @ patch ( 'gonzo.helpers.document_loader.requests.get' ) #NEWLINE# def test_arg_specified_url_source( req , minimum_config_fixture ) : #NEWLINE# #INDENT# ' Test that a user data file can be specified from cloud configuration\n    and then rendered with config and argument based parameters' #NEWLINE# hostname = 'staging-test-host-001' #NEWLINE# desired_subs = { #NEWLINE# #INDENT# 'key_1' : 'config_value_1' , #NEWLINE# 'key_2' : 'argument_value_2' , #NEWLINE# 'hostname' : hostname , #NEWLINE# #UNINDENT# } #NEWLINE# config_params = { #NEWLINE# #INDENT# 'key_1' : 'config_value_1' , #NEWLINE# 'key_2' : 'config_value_2' , #NEWLINE# #UNINDENT# } #NEWLINE# config_ud_url = 'http://this.should.not.be.requested.com/user-data.txt' #NEWLINE# config . get_cloud ( ) . update ( { #NEWLINE# #INDENT# 'DEFAULT_USER_DATA' : uri , #NEWLINE# 'USER_DATA_PARAMS' : config_params , #NEWLINE# #UNINDENT# } ) #NEWLINE# cli_params = csv_dict ( 'key_2=argument_value_2' ) #NEWLINE# cli_uri = 'http://this.should.be.requested.com/user-data.txt' #NEWLINE# uri = config . get_cloud_config_value ( 'DEFAULT_USER_DATA' , override = cli_uri ) #NEWLINE# ud_contents = '' #NEWLINE# for key in desired_subs . keys ( ) : #NEWLINE# #INDENT# ud_contents += ( '{{%s}} ' % key ) #NEWLINE# #UNINDENT# req . return_value = Mock ( text = ud_contents , status_code = 200 ) #NEWLINE# user_data = get_parsed_document ( entity_name = hostname , uri = uri , config_params_key = 'USER_DATA_PARAMS' , additional_params = cli_params ) #NEWLINE# assert_called_with ( req , uri ) #NEWLINE# for value in desired_subs . values ( ) : #NEWLINE# #INDENT# assert ( value in user_data )