tools/bdconfig/lib/google_hadoop/bdconfig_lib/xml_configuration_test.py
def testUpdateAndOptionalAdd(self):
    """Optionally update an existing property plus nonexistent one."""
    conf = xml_configuration.Configuration.EmptyConfiguration()
    properties_to_update = {
        'key1': 'value1',
        'key2': 'value2',
    }
    optional_properties_to_add = {
        'key2': 'value2_opt',
        'key3': 'value3_opt',
    }

    conf.Update(properties_to_update, optional_properties_to_add)

    # Updates are applied before optional properties, so they win if done
    # simultaneously.
    self.assertEqual('value1', conf.GetPropertyValue('key1'))
    self.assertEqual('value2', conf.GetPropertyValue('key2'))
    self.assertEqual('value3_opt', conf.GetPropertyValue('key3'))
    self.assertEqual(3, conf.GetNumProperties())

    properties_to_update = {
        'key1': None,
        'key2': None,
        'key3': None,
    }
    optional_properties_to_add = {
        'key2': 'value2_opt2',
        'key3': 'value3_opt2',
    }

    conf.Update(properties_to_update, optional_properties_to_add)

    # Setting 'None' is updates, and then adding in optional_properties_to_add
    # is equivalent to just putting the optional adds into the update instead
    # of 'None'.
    self.assertEqual(None, conf.GetPropertyValue('key1'))
    self.assertEqual('value2_opt2', conf.GetPropertyValue('key2'))
    self.assertEqual('value3_opt2', conf.GetPropertyValue('key3'))
    self.assertEqual(2, conf.GetNumProperties())
Optionally update an existing property plus nonexistent one.
Optionally update an existing property plus nonexistent one.
Optionally update an existing property plus nonexistent one .
def testUpdateAndOptionalAdd(self):
    conf = xml_configuration.Configuration.EmptyConfiguration()
    properties_to_update = {
        'key1': 'value1',
        'key2': 'value2',
    }
    optional_properties_to_add = {
        'key2': 'value2_opt',
        'key3': 'value3_opt',
    }
    conf.Update(properties_to_update, optional_properties_to_add)
    self.assertEqual('value1', conf.GetPropertyValue('key1'))
    self.assertEqual('value2', conf.GetPropertyValue('key2'))
    self.assertEqual('value3_opt', conf.GetPropertyValue('key3'))
    self.assertEqual(3, conf.GetNumProperties())
    properties_to_update = {
        'key1': None,
        'key2': None,
        'key3': None,
    }
    optional_properties_to_add = {
        'key2': 'value2_opt2',
        'key3': 'value3_opt2',
    }
    conf.Update(properties_to_update, optional_properties_to_add)
    self.assertEqual(None, conf.GetPropertyValue('key1'))
    self.assertEqual('value2_opt2', conf.GetPropertyValue('key2'))
    self.assertEqual('value3_opt2', conf.GetPropertyValue('key3'))
    self.assertEqual(2, conf.GetNumProperties())
def testUpdateAndOptionalAdd ( self ) : conf = xml_configuration . Configuration . EmptyConfiguration ( ) properties_to_update = { 'key1' : 'value1' , 'key2' : 'value2' , } optional_properties_to_add = { 'key2' : 'value2_opt' , 'key3' : 'value3_opt' , } conf . Update ( properties_to_update , optional_properties_to_add ) self . assertEqual ( 'value1' , conf . GetPropertyValue ( 'key1' ) ) self . assertEqual ( 'value2' , conf . GetPropertyValue ( 'key2' ) ) self . assertEqual ( 'value3_opt' , conf . GetPropertyValue ( 'key3' ) ) self . assertEqual ( 3 , conf . GetNumProperties ( ) ) properties_to_update = { 'key1' : None , 'key2' : None , 'key3' : None , } optional_properties_to_add = { 'key2' : 'value2_opt2' , 'key3' : 'value3_opt2' , } conf . Update ( properties_to_update , optional_properties_to_add ) self . assertEqual ( None , conf . GetPropertyValue ( 'key1' ) ) self . assertEqual ( 'value2_opt2' , conf . GetPropertyValue ( 'key2' ) ) self . assertEqual ( 'value3_opt2' , conf . GetPropertyValue ( 'key3' ) ) self . assertEqual ( 2 , conf . GetNumProperties ( ) )
Optionally update an existing property plus nonexistent one.
Optionally update an existing property plus nonexistent one .
"""Optionally update an existing property plus nonexistent one.""" # Updates are applied before optional properties, so they win if done # simultaneously. # Setting 'None' is updates, and then adding in optional_properties_to_add # is equivalent to just putting the optional adds into the update instead # of 'None'.
self