def test_will_throw_exception_if_value_for_puppet_module_directory_is_not_fount(self): single_service_yaml = """ apache1: puppet_module_directory : puppet apache2: puppet_manifest : apache.pp """ puppetServiceConfigurator = PuppetServiceConfigurator() error_list = [] valid = puppetServiceConfigurator.validate( "apache1", yaml.load(single_service_yaml)["apache1"], os.path.abspath("samples"), error_list ) self.assertFalse(valid) valid = puppetServiceConfigurator.validate( "apache2", yaml.load(single_service_yaml)["apache2"], os.path.abspath("samples"), error_list ) self.assertFalse(valid) self.assertEqual(len(error_list), 2) self.assertEqual( "Key 'puppet_manifest' is not defined in services configuration of service: 'apache1'", error_list[0] ) self.assertEqual( "Key 'puppet_module_directory' is not defined in services configuration of service: 'apache2'", error_list[1], )
def test_will_parse_puppet_service_configuration(self): single_service_yaml = """ apache: puppet_module_directory : puppet puppet_manifest : apache.pp """ puppetServiceConfigurator = PuppetServiceConfigurator() error_list = [] valid = puppetServiceConfigurator.validate( "apache", yaml.load(single_service_yaml)["apache"], os.path.abspath("samples"), error_list ) self.assertTrue(valid) self.assertEqual(len(error_list), 0)
def test_will_only_validate_yaml_if_config_path_found(self): single_service_yaml = """ apache: aa : aa """ puppetServiceConfigurator = PuppetServiceConfigurator() error_list = [] wrong_path = os.path.abspath("wrong path") valid = puppetServiceConfigurator.validate( "apache", yaml.load(single_service_yaml)["apache"], wrong_path, error_list ) self.assertFalse(valid) self.assertEqual(len(error_list), 1) self.assertEqual("Config path '" + wrong_path + "' not found", error_list[0])