def test_empty_component_save_and_load(self): ch = ConfigHolder(MACROS, MockVersionControl(), file_manager=MockConfigurationFileManager(), test_config=Configuration(MACROS)) ch.save_configuration("TESTCOMPONENT", True) ch.clear_config() conf = ch.load_configuration("TESTCOMPONENT", True) ch.set_config(conf, True) self.assertEqual(ch.get_config_name(), "TESTCOMPONENT") self.assertEqual(len(ch.get_blocknames()), 0) self.assertEqual(len(ch.get_group_details()), 0) self.assertEqual(len(ch.get_ioc_names()), 0) self.assertEqual(len(ch.get_component_names()), 0)
def test_default_component_is_loaded(self): # Arrange ch = ConfigHolder(MACROS, MockVersionControl(), file_manager=MockConfigurationFileManager(), test_config=Configuration(MACROS)) ch.save_configuration("TESTCONFIG", False) ch.clear_config() # Act conf = ch.load_configuration("TESTCONFIG") ch.set_config(conf, False) # Assert comp_count = len(ch.get_component_names()) comp_count_with_default = len(ch.get_component_names(True)) self.assertTrue(comp_count_with_default > comp_count)
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)