diff --git a/eva_sub_cli/validators/validation_results_parsers.py b/eva_sub_cli/validators/validation_results_parsers.py index ed92ad0..274b7a6 100644 --- a/eva_sub_cli/validators/validation_results_parsers.py +++ b/eva_sub_cli/validators/validation_results_parsers.py @@ -134,6 +134,10 @@ def clean_read(ifile): if line.startswith('Validation failed with following error(s):'): collect = True else: + while line and not line.startswith('/'): + # Sometimes there are multiple (possibly redundant) errors listed under a single property, + # we only report the first + line = clean_read(open_file) line2 = clean_read(open_file) if line is None or line2 is None: break # EOF diff --git a/tests/resources/validation_reports/validation_output/other_validations/metadata_validation.txt b/tests/resources/validation_reports/validation_output/other_validations/metadata_validation.txt index 3b805ec..0bc227e 100644 --- a/tests/resources/validation_reports/validation_output/other_validations/metadata_validation.txt +++ b/tests/resources/validation_reports/validation_output/other_validations/metadata_validation.txt @@ -26,4 +26,19 @@ should have required property 'bioSampleObject' /sample/0 should match exactly one schema in oneOf +/sample/3/bioSampleObject/name + must have required property 'name' + must have required property 'name' + must have required property 'name' +/sample/3/bioSampleObject/characteristics/organism + must have required property 'organism' + must have required property 'organism' +/sample/3/bioSampleObject/characteristics/Organism + must have required property 'Organism' +/sample/3/bioSampleObject/characteristics/species + must have required property 'species' +/sample/3/bioSampleObject/characteristics/Species + must have required property 'Species' +/sample/3/bioSampleObject/characteristics + must match a schema in anyOf  diff --git a/tests/test_validator.py b/tests/test_validator.py index 19f0ea9..6a65a87 100644 --- a/tests/test_validator.py +++ b/tests/test_validator.py @@ -71,6 +71,17 @@ def test__collect_validation_workflow_results_with_metadata_xlsx(self): {'property': '/sample/0/bioSampleAccession', 'description': "should have required property 'bioSampleAccession'"}, {'property': '/sample/0/bioSampleObject', 'description': "should have required property 'bioSampleObject'"}, {'property': '/sample/0', 'description': 'should match exactly one schema in oneOf'}, + {'property': '/sample/3/bioSampleObject/name', 'description': "must have required property 'name'"}, + {'property': '/sample/3/bioSampleObject/characteristics/organism', + 'description': "must have required property 'organism'"}, + {'property': '/sample/3/bioSampleObject/characteristics/Organism', + 'description': "must have required property 'Organism'"}, + {'property': '/sample/3/bioSampleObject/characteristics/species', + 'description': "must have required property 'species'"}, + {'property': '/sample/3/bioSampleObject/characteristics/Species', + 'description': "must have required property 'Species'"}, + {'property': '/sample/3/bioSampleObject/characteristics', + 'description': 'must match a schema in anyOf'}, {'property': '/project/childProjects/1', 'description': 'PRJEBNA does not exist or is private'}, {'property': '/sample/2/bioSampleObject/characteristics/taxId', 'description': '1234 is not a valid taxonomy code'}, @@ -95,6 +106,10 @@ def test__collect_validation_workflow_results_with_metadata_xlsx(self): 'description': 'Column "Reference" is not populated'}, {'sheet': 'Sample', 'row': 3, 'column': 'Sample Accession', 'description': 'Column "Sample Accession" is not populated'}, + {'sheet': 'Sample', 'row': 6, 'column': 'BioSample Name', + 'description': 'Column "BioSample Name" is not populated'}, + {'sheet': 'Sample', 'row': 6, 'column': 'Scientific Name', + 'description': 'Column "Scientific Name" is not populated'}, {'sheet': 'Project', 'row': 2, 'column': 'Child Project(s)', 'description': 'PRJEBNA does not exist or is private'}, {'sheet': 'Sample', 'row': 5, 'column': 'Tax Id', @@ -162,6 +177,17 @@ def test__collect_validation_workflow_results_with_metadata_json(self): {'property': '/sample/0/bioSampleObject', 'description': "should have required property 'bioSampleObject'"}, {'property': '/sample/0', 'description': 'should match exactly one schema in oneOf'}, + {'property': '/sample/3/bioSampleObject/name', 'description': "must have required property 'name'"}, + {'property': '/sample/3/bioSampleObject/characteristics/organism', + 'description': "must have required property 'organism'"}, + {'property': '/sample/3/bioSampleObject/characteristics/Organism', + 'description': "must have required property 'Organism'"}, + {'property': '/sample/3/bioSampleObject/characteristics/species', + 'description': "must have required property 'species'"}, + {'property': '/sample/3/bioSampleObject/characteristics/Species', + 'description': "must have required property 'Species'"}, + {'property': '/sample/3/bioSampleObject/characteristics', + 'description': 'must match a schema in anyOf'}, {'property': '/project/childProjects/1', 'description': 'PRJEBNA does not exist or is private'}, {'property': '/sample/2/bioSampleObject/characteristics/taxId', 'description': '1234 is not a valid taxonomy code'}, @@ -201,10 +227,22 @@ def test_parse_biovalidator_validation_results(self): {'property': '/project/taxId', 'description': "must have required property 'taxId'"}, {'property': '/project/holdDate', 'description': 'must match format "date"'}, {'property': '/analysis/0/description', 'description': "should have required property 'description'"}, - {'property': '/analysis/0/referenceGenome', 'description': "should have required property 'referenceGenome'"}, - {'property': '/sample/0/bioSampleAccession', 'description': "should have required property 'bioSampleAccession'"}, + {'property': '/analysis/0/referenceGenome', + 'description': "should have required property 'referenceGenome'"}, + {'property': '/sample/0/bioSampleAccession', + 'description': "should have required property 'bioSampleAccession'"}, {'property': '/sample/0/bioSampleObject', 'description': "should have required property 'bioSampleObject'"}, - {'property': '/sample/0', 'description': 'should match exactly one schema in oneOf'} + {'property': '/sample/0', 'description': 'should match exactly one schema in oneOf'}, + {'property': '/sample/3/bioSampleObject/name', 'description': "must have required property 'name'"}, + {'property': '/sample/3/bioSampleObject/characteristics/organism', + 'description': "must have required property 'organism'"}, + {'property': '/sample/3/bioSampleObject/characteristics/Organism', + 'description': "must have required property 'Organism'"}, + {'property': '/sample/3/bioSampleObject/characteristics/species', + 'description': "must have required property 'species'"}, + {'property': '/sample/3/bioSampleObject/characteristics/Species', + 'description': "must have required property 'Species'"}, + {'property': '/sample/3/bioSampleObject/characteristics', 'description': 'must match a schema in anyOf'} ] def test_convert_biovalidator_validation_to_spreadsheet(self):