def _job_def(id_): try: job_loc = _get_job_file(id_, 'main.yml') object = read_yaml(job_loc) job_def = JobDefinition(tasks=[]) job_def.location = job_loc job_def.name = id_ job_def.id = id_ for t in object['tasks']: if 'mounts' not in t: t['mounts'] = t.pop('mount') name = t['name'] t['id'] = f'{id_}--{name}' task_def = TaskDefinition(**t) job_def.tasks.append(task_def) job_def.configs = _get_job_files(job_loc) return job_def except: return None
def test_read_yaml_strict(): pytest.importorskip('yaml') with pytest.raises(IOError): read_yaml(os.path.join('not_there.yml'), strict=True)
def test_read_yaml_given_default(): pytest.importorskip('yaml') gold_default = 'default' data = read_yaml(os.path.join('not_there.yml'), gold_default) assert data == gold_default
def test_read_yaml_default_value(): pytest.importorskip('yaml') gold_default = {} data = read_yaml(os.path.join(data_loc, 'not_there.yml')) assert data == gold_default
def test_read_yaml(gold_data): pytest.importorskip('yaml') data = read_yaml(os.path.join(data_loc, 'test_yaml.yml')) assert data == gold_data