示例#1
0
def test_draft_validate():
    schema = utils.load_schema('hep')

    record = {
        '_collections': [
            'Literature',
        ],
        'document_type': [
            'article',
        ],
        'titles': [
            {'title': 'A title'},
        ],
        'preprint_date': 'Jessica Jones'
    }
    expected = 'Jessica Jones'
    result = utils.get_validation_errors(record, schema)
    error = next(result)

    assert expected in error.message
    with pytest.raises(StopIteration):
        error = next(result)
示例#2
0
 def get_validation_errors(self):
     if not hasattr(self, "_validation_errors"):
         self._validation_errors = list(get_validation_errors(self))
     return self._validation_errors
示例#3
0
 def validate(self):
     self._validation_errors = list(get_validation_errors(self))
     if self._validation_errors:
         raise self._validation_errors[0]