tools/bdconfig/lib/google_hadoop/bdconfig_lib/xml_configuration_test.py
def testUpdateOptionalAddAndRemove(self):
    """Properties takes precendence over pptional properties"""
    conf = xml_configuration.Configuration.EmptyConfiguration()
    properties_to_update = {}
    optional_properties_to_add = {
        'key1': 'value1',
        'key2': 'value2',
    }

    conf.Update(properties_to_update, optional_properties_to_add)

    self.assertEqual('value1', conf.GetPropertyValue('key1'))
    self.assertEqual('value2', conf.GetPropertyValue('key2'))
    self.assertEqual(2, conf.GetNumProperties())

    optional_properties_to_add = {
        'key2': 'value2_new',
        'key3': 'value3',
    }

    conf.Update(properties_to_update, optional_properties_to_add)

    # value2 unchanged, value3 added.
    self.assertEqual('value1', conf.GetPropertyValue('key1'))
    self.assertEqual('value2', conf.GetPropertyValue('key2'))
    self.assertEqual('value3', conf.GetPropertyValue('key3'))
    self.assertEqual(3, conf.GetNumProperties())

    # It is an error to true to 'delete' a property using the
    # optional_properties_to_add.
    optional_properties_to_add = {
        'key1': None,
    }
    self.assertRaises(
        LookupError, conf.Update,
        properties_to_update, optional_properties_to_add)

    self.assertEqual('value1', conf.GetPropertyValue('key1'))
    self.assertEqual('value2', conf.GetPropertyValue('key2'))
    self.assertEqual('value3', conf.GetPropertyValue('key3'))
    self.assertEqual(3, conf.GetNumProperties())
Properties takes precendence over pptional properties
Properties takes precendence over pptional properties
Properties takes precendence over pptional properties
def testUpdateOptionalAddAndRemove(self):
    conf = xml_configuration.Configuration.EmptyConfiguration()
    properties_to_update = {}
    optional_properties_to_add = {
        'key1': 'value1',
        'key2': 'value2',
    }
    conf.Update(properties_to_update, optional_properties_to_add)
    self.assertEqual('value1', conf.GetPropertyValue('key1'))
    self.assertEqual('value2', conf.GetPropertyValue('key2'))
    self.assertEqual(2, conf.GetNumProperties())
    optional_properties_to_add = {
        'key2': 'value2_new',
        'key3': 'value3',
    }
    conf.Update(properties_to_update, optional_properties_to_add)
    self.assertEqual('value1', conf.GetPropertyValue('key1'))
    self.assertEqual('value2', conf.GetPropertyValue('key2'))
    self.assertEqual('value3', conf.GetPropertyValue('key3'))
    self.assertEqual(3, conf.GetNumProperties())
    optional_properties_to_add = {
        'key1': None,
    }
    self.assertRaises(
        LookupError, conf.Update,
        properties_to_update, optional_properties_to_add)
    self.assertEqual('value1', conf.GetPropertyValue('key1'))
    self.assertEqual('value2', conf.GetPropertyValue('key2'))
    self.assertEqual('value3', conf.GetPropertyValue('key3'))
    self.assertEqual(3, conf.GetNumProperties())
def testUpdateOptionalAddAndRemove ( self ) : conf = xml_configuration . Configuration . EmptyConfiguration ( ) properties_to_update = { } optional_properties_to_add = { 'key1' : 'value1' , 'key2' : 'value2' , } conf . Update ( properties_to_update , optional_properties_to_add ) self . assertEqual ( 'value1' , conf . GetPropertyValue ( 'key1' ) ) self . assertEqual ( 'value2' , conf . GetPropertyValue ( 'key2' ) ) self . assertEqual ( 2 , conf . GetNumProperties ( ) ) optional_properties_to_add = { 'key2' : 'value2_new' , 'key3' : 'value3' , } conf . Update ( properties_to_update , optional_properties_to_add ) self . assertEqual ( 'value1' , conf . GetPropertyValue ( 'key1' ) ) self . assertEqual ( 'value2' , conf . GetPropertyValue ( 'key2' ) ) self . assertEqual ( 'value3' , conf . GetPropertyValue ( 'key3' ) ) self . assertEqual ( 3 , conf . GetNumProperties ( ) ) optional_properties_to_add = { 'key1' : None , } self . assertRaises ( LookupError , conf . Update , properties_to_update , optional_properties_to_add ) self . assertEqual ( 'value1' , conf . GetPropertyValue ( 'key1' ) ) self . assertEqual ( 'value2' , conf . GetPropertyValue ( 'key2' ) ) self . assertEqual ( 'value3' , conf . GetPropertyValue ( 'key3' ) ) self . assertEqual ( 3 , conf . GetNumProperties ( ) )
Properties takes precendence over pptional properties
Properties takes precendence over pptional properties
"""Properties takes precendence over pptional properties""" # value2 unchanged, value3 added. # It is an error to true to 'delete' a property using the # optional_properties_to_add.
self