Esempio n. 1
0
def test_description_type_validation(value, MESSAGES, msg_assertions):
    with pytest.raises(ValidationError) as err:
        single_header_validator({'description': value})

    msg_assertions.assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'description.type',
    )
Esempio n. 2
0
def test_description_with_valid_value(msg_assertions):
    try:
        single_header_validator({'description': 'abc def'})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('description', errors)
Esempio n. 3
0
def test_type_with_valid_singular_value(value, msg_assertions):
    try:
        single_header_validator({'type': value})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('type', errors)
Esempio n. 4
0
def test_description_is_not_required(msg_assertions):
    try:
        single_header_validator({})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('description', errors)
Esempio n. 5
0
def test_type_is_required(MESSAGES, msg_assertions):
    with pytest.raises(ValidationError) as err:
        single_header_validator({})

    msg_assertions.assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        'required.type',
    )
Esempio n. 6
0
def test_multiple_type_with_unknown_type(msg_assertions, MESSAGES):
    with pytest.raises(ValidationError) as err:
        single_header_validator({'type': [STRING, 'not-a-known-type']})

    msg_assertions.assert_message_in_errors(
        MESSAGES['enum']['invalid'],
        err.value.detail,
        'type',
    )
Esempio n. 7
0
def test_collection_format_with_valid_value(msg_assertions):
    try:
        single_header_validator({'collectionFormat': CSV})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('collectionFormat', errors)
Esempio n. 8
0
def test_collection_format_type_validation(value, MESSAGES, msg_assertions):
    with pytest.raises(ValidationError) as err:
        single_header_validator({'collectionFormat': value})

    msg_assertions.assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'collectionFormat.type',
    )
def test_collection_format_with_valid_value(msg_assertions):
    try:
        single_header_validator({'collectionFormat': CSV})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('collectionFormat', errors)
def test_collection_format_type_validation(value, MESSAGES, msg_assertions):
    with pytest.raises(ValidationError) as err:
        single_header_validator({'collectionFormat': value})

    msg_assertions.assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'collectionFormat.type',
    )
Esempio n. 11
0
def test_items_is_required_if_type_array(msg_assertions, MESSAGES):
    with pytest.raises(ValidationError) as err:
        single_header_validator({'type': ARRAY})

    msg_assertions.assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        'items',
    )