def test_load_empty(): yaml_fo = tempfile.NamedTemporaryFile() config_data = config_file.load(yaml_fo.name) log.debug('config_data: %s', config_data) assert config_data is None
def load(full_file_path): '''Load the yaml config file at full_file_path and create and return an instance of Config''' config_file_data = config_file.load(full_file_path) _default_conf_data = collections.OrderedDict(defaults.DEFAULTS) config_data = config_file_data or _default_conf_data log.debug('config_data: %s', config_data) return Config.from_dict(config_data)
def test_load_busted_yaml(): yaml_fo = tempfile.NamedTemporaryFile() yaml_fo.write(BAD_YAML) yaml_fo.flush() try: config_data = config_file.load(yaml_fo.name) except exceptions.GalaxyConfigFileError as e: log.debug(e, exc_info=True) return log.debug('config_data: %s', config_data) assert config_data, 'A GalaxyConfigFileError was expected here'
def load(full_file_path): '''Load the yaml config file at full_file_path and create and return an instance of Config''' config_file_data = config_file.load(full_file_path) _default_conf_data = collections.OrderedDict(defaults.DEFAULTS) config_data = config_file_data or _default_conf_data for key in _default_conf_data: # If an expected key is not defined, set it to the default value if key not in config_data: config_data[key] = _default_conf_data[key] log.debug('config_data: %s', config_data) return Config.from_dict(config_data)
def test_load_valid_yaml(): yaml_fo = tempfile.NamedTemporaryFile() yaml_fo.write(VALID_YAML) yaml_fo.flush() config_data = config_file.load(yaml_fo.name) log.debug('config_data: %s', config_data) assert config_data is not None expected_keys = ['server', 'content_path', 'options'] for expected_key in expected_keys: assert expected_key in config_data assert config_data['server']['url'] == 'https://someserver.example.com' assert config_data['server']['ignore_certs'] is True assert config_data['content_path'] == '~/.ansible/some_content_path' assert config_data['options']['role_skeleton_path'] == '~/.some_skeleton'
def test_load_bogus_path(): bogus_path = '/dev/null/doesnt/exist.yml' config_data = config_file.load(bogus_path) log.debug('config_data: %s', config_data) assert config_data is None