From 97089c06e84b644e7a7d930e498fca3de6509fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sinclert=20P=C3=A9rez?= Date: Thu, 14 May 2020 11:20:02 +0200 Subject: [PATCH] Add UDS exception its own test --- hepdata_validator/data_file_validator.py | 2 +- testsuite/test_data_validator.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hepdata_validator/data_file_validator.py b/hepdata_validator/data_file_validator.py index c103450..fd43d92 100644 --- a/hepdata_validator/data_file_validator.py +++ b/hepdata_validator/data_file_validator.py @@ -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, diff --git a/testsuite/test_data_validator.py b/testsuite/test_data_validator.py index 1c5e4b4..bc57147 100644 --- a/testsuite/test_data_validator.py +++ b/testsuite/test_data_validator.py @@ -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 = {}