def test_stage_load_on_invalid_data(tmp_dir, dvc, file): data = {"is_this_a_valid_dvcfile": False} dump_yaml(file, data) dvcfile = Dvcfile(dvc, file) with pytest.raises(StageFileFormatError): assert dvcfile.stages with pytest.raises(StageFileFormatError): assert dvcfile.validate(data, file)
def test_stage_load_on_invalid_data(tmp_dir, dvc, file): data = {"is_this_a_valid_dvcfile": False} (tmp_dir / file).dump(data) dvcfile = Dvcfile(dvc, file) with pytest.raises(YAMLValidationError): assert dvcfile.stages with pytest.raises(YAMLValidationError): assert dvcfile.validate(data, file)
def test_list(): lst = [ { OutputLOCAL.PARAM_PATH: "foo", RemoteLOCAL.PARAM_CHECKSUM: "123" }, { OutputLOCAL.PARAM_PATH: "bar", RemoteLOCAL.PARAM_CHECKSUM: None }, { OutputLOCAL.PARAM_PATH: "baz" }, ] d = {Stage.PARAM_DEPS: lst} Dvcfile.validate(d) lst[0][OutputLOCAL.PARAM_CACHE] = True lst[1][OutputLOCAL.PARAM_CACHE] = False d = {Stage.PARAM_OUTS: lst} Dvcfile.validate(d)
def test_empty_list(): d = {Stage.PARAM_DEPS: []} Dvcfile.validate(d) d = {Stage.PARAM_OUTS: []} Dvcfile.validate(d)
def test_none(): Dvcfile.validate({Stage.PARAM_DEPS: None}) Dvcfile.validate({Stage.PARAM_OUTS: None})
def test_object(): with pytest.raises(StageFileFormatError): Dvcfile.validate({Stage.PARAM_DEPS: {}}) with pytest.raises(StageFileFormatError): Dvcfile.validate({Stage.PARAM_OUTS: {}})
def test_cmd_str(): Dvcfile.validate({Stage.PARAM_CMD: "cmd"})
def test_no_cmd(): Dvcfile.validate({})
def test_cmd_none(): Dvcfile.validate({Stage.PARAM_CMD: None})
def test_cmd_obj(): with pytest.raises(StageFileFormatError): Dvcfile.validate({Stage.PARAM_CMD: {}})