Пример #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]