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', )
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)
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)
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)
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', )
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', )
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', )
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', )
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', )