Skip to content

Commit

Permalink
Add UDS exception its own test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinclert authored and GraemeWatt committed May 26, 2020
1 parent 7346103 commit 97089c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hepdata_validator/data_file_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def validate(self, **kwargs):
message=ve.message + ' in ' + str(ve.instance),
))

except Exception as ex:
except UnsupportedDataSchemaException as ex:
self.add_validation_message(ValidationMessage(
file=file_path,
message=ex.message,
Expand Down
19 changes: 17 additions & 2 deletions testsuite/test_data_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,24 @@ def test_validate_valid_custom_data_type(validator_v1, data_path):
assert is_valid is True


def test_load_invalid_custom_schema_v1(validator_v1):
def test_validate_undefined_data_type(validator_v1, data_path):
"""
Tests the DataFileValidator V1 against an unsupported schema
Tests the DataFileValidator V1 validation of an unsupported schema
"""

file_path = os.path.join(data_path, 'valid_file_custom.yaml')
file_type = 'undefined'

is_valid = validator_v1.validate(file_path=file_path, file_type=file_type)
errors = validator_v1.get_messages(file_name=file_path)

assert is_valid is False
assert len(errors) == 1


def test_load_undefined_custom_schema_v1(validator_v1):
"""
Tests the DataFileValidator V1 loading of an unsupported schema
"""

validator_v1.custom_data_schemas = {}
Expand Down

0 comments on commit 97089c0

Please sign in to comment.