from MDFValidate.validator import MDFValidator
import sys

test_me = ["mdf-schema.yaml", "icdc-model.yml", "icdc-model-props.yml"]
# v = MDFValidator("mdf-schema.yaml", "icdc-model.yml","icdc-model-props.yml")
if len(sys.argv) > 1:
    test_me = sys.argv[1:]

v = MDFValidator(*test_me)


def test_model_valid():
    assert v.validate() == None


if __name__ == '__main__':
    v.validate()
Esempio n. 2
0
from sys import path
path.append('../bento-mdf/validators/mdf-validate')
from MDFValidate.validator import MDFValidator

v = MDFValidator('../bento-mdf/schema/mdf-schema.yaml',
                   'bento_model_file.yaml','bento_model_properties.yaml')

def test():
  v.test_yaml_valid()
  v.test_model_valid()
Esempio n. 3
0
def test_list_type():
  v = MDFValidator(None, *test_list_type_files)
  assert v
  assert v.load_and_validate_yaml()
Esempio n. 4
0
                nargs='+',
                metavar='mdf-file',
                type=FileType('r'),
                help="MDF yaml files for validation")


def test(v):
    retval = 0
    try:
        v.load_and_validate_schema()
    except:
        retval += 1
        pass
    try:
        v.load_and_validate_yaml()
    except:
        retval += 1
        pass
    try:
        v.validate_instance_with_schema()
    except:
        retval += 1
        pass
    return retval


if __name__ == '__main__':
    args = ap.parse_args()
    v = MDFValidator(args.schema, verbose=(not args.quiet), *args.mdf_files)
    exit(test(v))  # emit return val (0 = good) to os
Esempio n. 5
0
def test_bad_schema():
  # pytest.skip()
  v =  MDFValidator(test_schema_bad)
  with pytest.raises(SchemaError):
    v.load_and_validate_schema()
Esempio n. 6
0
def test_instance_not_valid_wrt_schema():
  v =  MDFValidator(test_schema_file, *test_mdf_files_invalid_wrt_schema)  
  assert v.load_and_validate_schema()
  assert v.load_and_validate_yaml()
  with pytest.raises(ValidationError):
    v.validate_instance_with_schema()
Esempio n. 7
0
def test_keydup_yaml():
  v = MDFValidator(test_schema_file, test_yaml_with_keydup)
  with pytest.raises(ConstructorError):
    v.load_and_validate_yaml()
Esempio n. 8
0
def test_bad_yaml():
  v = MDFValidator(test_schema_file, test_yaml_bad)
  with pytest.raises(ParserError):
    v.load_and_validate_yaml()
Esempio n. 9
0
def test_with_remote_schema():
  v = MDFValidator(None, *test_mdf_files)
  assert v
  assert v.load_and_validate_schema()
  assert v.load_and_validate_yaml()
Esempio n. 10
0
def test_with_all_str_args():
  assert MDFValidator(test_schema_file, *test_mdf_files)
Esempio n. 11
0
def test_with_all_File_args():
  sch = open(test_schema_file,"r")
  mdf0 = open(test_mdf_files[0],"r")
  mdf1 = open(test_mdf_files[1],"r")  
  assert MDFValidator(sch, mdf0, mdf1)