def test_tree_del_repeated_all_elms(self): data = RPD_DB() data.data.Clear() self._create_repeated_list(data) data.del_tree({'cfg': {'DsOfdmProfile': {2: None, 1: None}}}) value = data.get_val(['cfg']) self.assertIsNone(value)
def test_tree_del_repeated_one_key(self): data = RPD_DB() data.data.Clear() self._create_repeated_list(data) data.del_tree({ 'cfg': { 'DsOfdmProfile': { 2: { 'DsOfdmSubcarrierModulation': { 21: None } } } } }) value = data.get_val(['cfg']) self.assertEqual(len(value.ListFields()), 1) value = data.get_val(['cfg', 'DsOfdmProfile']) self.assertEqual(len(value), 2) value = data.get_val( ['cfg', 'DsOfdmProfile', 1, 'DsOfdmSubcarrierModulation']) self.assertEqual(len(value), 1) value = data.get_val( ['cfg', 'DsOfdmProfile', 2, 'DsOfdmSubcarrierModulation']) self.assertListEqual([x.StartSubcarrierId for x in value], [22])
def test_tree_del_container(self): data = RPD_DB() data.data.cfg.RpdCapabilities.NumBdirPorts = 5 data.data.cfg.DsScQamChannelConfig.PowerAdjust = 2 data.del_tree({'cfg': {'DsScQamChannelConfig': None}}) value = data.get_val(['cfg', 'DsScQamChannelConfig']) self.assertIsNone(value) value = data.get_val(['cfg']) # RpdCapabilities subtree should stay here self.assertEqual(len(value.ListFields()), 1)
def test_tree_del_leaf(self): data = RPD_DB() data.data.Clear() data.data.cfg.RpdCapabilities.NumBdirPorts = 5 data.data.cfg.RpdCapabilities.NumDsRfPorts = 2 data.del_tree({'cfg': {'RpdCapabilities': {'NumBdirPorts': None}}}) value = data.get_val(['cfg', 'RpdCapabilities']) self.assertEqual(len(value.ListFields()), 1) self.assertIsNone( data.get_val(['cfg', 'RpdCapabilities', 'NumBdirPorts'])) self.assertEqual( data.get_val(['cfg', 'RpdCapabilities', 'NumDsRfPorts']), 2)
def test_tree_del_more_values(self): data = RPD_DB() data.data.Clear() data.data.cfg.RpdCapabilities.NumBdirPorts = 5 data.data.cfg.DsScQamChannelConfig.PowerAdjust = 2 data.data.cfg.RpdCapabilities.NumDsRfPorts = 4 data.del_tree({ 'cfg': { 'DsScQamChannelConfig': { 'PowerAdjust': None }, 'RpdCapabilities': { 'NumDsRfPorts': None } } }) value = data.get_val(['cfg']) self.assertEqual(len(value.ListFields()), 1) value = data.get_val(['cfg', 'RpdCapabilities']) self.assertEqual(len(value.ListFields()), 1)