<s> import copy <EOL> import xml . dom . minidom as xml <EOL> import mock <EOL> from sahara . plugins . spark import config_helper as c_helper <EOL> from sahara . swift import swift_helper as swift <EOL> from sahara . tests . unit import base as test_base <EOL> from sahara . utils import xmlutils <EOL> class ConfigHelperUtilsTest ( test_base . SaharaTestCase ) : <EOL> def test_make_hadoop_path ( self ) : <EOL> storage_paths = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> paths = c_helper . make_hadoop_path ( storage_paths , '<STR_LIT>' ) <EOL> expected = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . assertEqual ( expected , paths ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_cleanup_configs ( self , get_config_value ) : <EOL> getter = lambda plugin , key , cluster : plugin_configs [ key ] <EOL> get_config_value . side_effect = getter <EOL> plugin_configs = { "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> } <EOL> configs = c_helper . generate_job_cleanup_config ( None ) <EOL> self . assertTrue ( configs [ '<STR_LIT>' ] ) <EOL> expected = [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> for config_value in expected : <EOL> self . assertIn ( config_value , configs [ '<STR_LIT>' ] ) <EOL> self . assertIn ( "<STR_LIT>" , <EOL> configs [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> plugin_configs [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> configs = c_helper . generate_job_cleanup_config ( None ) <EOL> self . assertFalse ( configs [ '<STR_LIT>' ] ) <EOL> self . assertNotIn ( configs , '<STR_LIT>' ) <EOL> self . assertNotIn ( configs , '<STR_LIT>' ) <EOL> plugin_configs = { "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT> } <EOL> configs = c_helper . generate_job_cleanup_config ( None ) <EOL> self . assertFalse ( configs [ '<STR_LIT>' ] ) <EOL> self . assertNotIn ( configs , '<STR_LIT>' ) <EOL> self . assertNotIn ( configs , '<STR_LIT>' ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_generate_xml_configs ( self , auth_url ) : <EOL> auth_url . return_value = "<STR_LIT>" <EOL> swift_vals = c_helper . extract_name_values ( swift . get_swift_configs ( ) ) <EOL> c = c_helper . generate_xml_configs ( { } , [ '<STR_LIT>' ] , '<STR_LIT:localhost>' , None ) <EOL> doc = xml . parseString ( c [ '<STR_LIT>' ] ) <EOL> configuration = doc . getElementsByTagName ( '<STR_LIT>' ) <EOL> properties = xmlutils . get_property_dict ( configuration [ <NUM_LIT:0> ] ) <EOL> self . assertDictContainsSubset ( swift_vals , properties ) <EOL> c = c_helper . generate_xml_configs ( <EOL> { '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } , <EOL> [ '<STR_LIT>' ] , '<STR_LIT:localhost>' , None ) <EOL> doc = xml . parseString ( c [ '<STR_LIT>' ] ) <EOL> configuration = doc . getElementsByTagName ( '<STR_LIT>' ) <EOL> properties = xmlutils . get_property_dict ( configuration [ <NUM_LIT:0> ] ) <EOL> mod_swift_vals = copy . copy ( swift_vals ) <EOL> mod_swift_vals [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertDictContainsSubset ( mod_swift_vals , properties ) <EOL> c = c_helper . generate_xml_configs ( <EOL> { '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : False } } , <EOL> [ '<STR_LIT>' ] , '<STR_LIT:localhost>' , None ) <EOL> doc = xml . parseString ( c [ '<STR_LIT>' ] ) <EOL> configuration = doc . getElementsByTagName ( '<STR_LIT>' ) <EOL> properties = xmlutils . get_property_dict ( configuration [ <NUM_LIT:0> ] ) <EOL> for key in mod_swift_vals . keys ( ) : <EOL> self . assertNotIn ( key , properties ) </s>
