def test_add_ioc_component(self): ch = ConfigHolder(MACROS, MockVersionControl(), file_manager=MockConfigurationFileManager(), test_config=Configuration(MACROS)) ch.add_component("TESTCOMPONENT", Configuration(MACROS)) ch._add_ioc("TESTIOC1", "TESTCOMPONENT") ioc_details = ch.get_ioc_names() self.assertEqual(len(ioc_details), 1) self.assertTrue("TESTIOC1" in ioc_details)
def test_save_comp_add_to_config(self): # Create and save a component ch = ConfigHolder(MACROS, MockVersionControl(), file_manager=MockConfigurationFileManager(), test_config=create_dummy_component()) ch.save_configuration("TESTCOMPONENT", True) ch.clear_config() # Create and save a config that uses the component ch.set_config(create_dummy_config()) comp = ch.load_configuration("TESTCOMPONENT", True) ch.add_component("TESTCOMPONENT", comp) ch.save_configuration("TESTCONFIG", False) ch.clear_config() conf = ch.load_configuration("TESTCONFIG", False) ch.set_config(conf) self.assertEqual(len(ch.get_component_names()), 1)
def test_get_config_details_add_component(self): ch = ConfigHolder(MACROS, MockVersionControl(), file_manager=MockConfigurationFileManager(), test_config=Configuration(MACROS)) comp = create_dummy_component() ch.add_component("TESTCOMPONENT", comp) details = ch.get_config_details() self.assertEqual(len(details['blocks']), 2) blks = [x['name'] for x in details['blocks']] self.assertTrue("COMPBLOCK1" in blks) self.assertTrue("COMPBLOCK2" in blks) self.assertEqual(len(details['groups']), 2) self.assertEqual(details['groups'][0]['blocks'], ["COMPBLOCK1"]) self.assertEqual(details['groups'][1]['blocks'], ["COMPBLOCK2"]) self.assertEqual(len(details['iocs']), 0) iocs = [x['name'] for x in details['iocs']] self.assertFalse("COMPSIMPLE1" in iocs) self.assertEqual(len(details['components']), 1)