Ejemplo n.º 1
0
def test_extended_validation(app, ill_request_martigny_data_tmp):
    """Test extended validation for ill request."""
    data = ill_request_martigny_data_tmp

    # pages are reqiured if request is a request copy
    data['copy'] = True
    if 'pages' in data:
        del data['pages']
    with pytest.raises(RecordValidationError):
        ILLRequest.validate(ILLRequest(data))
def test_extended_validation(app, ill_request_martigny_data_tmp):
    """Test extended validation for ill request."""
    data = copy.deepcopy(ill_request_martigny_data_tmp)

    # pages are required if request is a request copy
    data['copy'] = True
    if 'pages' in data:
        del data['pages']
    with pytest.raises(RecordValidationError):
        ILLRequest.validate(ILLRequest(data))

    # test on 'notes' field :: have 2 note of the same type is disallowed
    data = copy.deepcopy(ill_request_martigny_data_tmp)
    data['notes'] = [{
        'type': ILLRequestNoteStatus.PUBLIC_NOTE,
        'content': 'dummy content'
    }]
    ILLRequest.validate(ILLRequest(data))
    with pytest.raises(RecordValidationError):
        data['notes'].append({
            'type': ILLRequestNoteStatus.PUBLIC_NOTE,
            'content': 'second dummy note'
        })
        ILLRequest.validate(ILLRequest(data))