def test_schema_with_valid_value(msg_assertions): try: single_response_validator({'schema': {}}) except ValidationError as err: errors = err.detail else: errors = {} msg_assertions.assert_path_not_in_errors('schema', errors)
def test_schema_is_not_required(msg_assertions): try: single_response_validator({}) except ValidationError as err: errors = err.detail else: errors = {} msg_assertions.assert_path_not_in_errors('schema', errors)
def test_headers_validation_with_valid_type(): try: single_response_validator({'headers': {}}) except ValidationError as err: errors = err.detail else: errors = {} assert_path_not_in_errors('headers', errors)
def test_schema_type_validation(value, MESSAGES, msg_assertions): with pytest.raises(ValidationError) as err: single_response_validator({'schema': value}) msg_assertions.assert_message_in_errors( MESSAGES['type']['invalid'], err.value.detail, 'schema.type', )
def test_headers_is_not_required(): try: single_response_validator({}) except ValidationError as err: errors = err.detail else: errors = {} assert_path_not_in_errors('headers', errors)
def test_headers_validation_with_invalid_types(value): context = {'deferred_references': set()} with pytest.raises(ValidationError) as err: single_response_validator({'headers': value}, context=context) assert_message_in_errors( MESSAGES['type']['invalid'], err.value.detail, 'headers.type', )
def test_schema_validation_with_invalid_types(value): context = {'deferred_references': set()} response_definition = ResponseDefinitionFactory(schema=value) with pytest.raises(ValidationError) as err: single_response_validator(response_definition, context=context) assert_message_in_errors( MESSAGES['type']['invalid'], err.value.detail, 'schema.type', )
def test_schema_is_not_required(): context = {'deferred_references': set()} response_definition = ResponseDefinitionFactory() response_definition.pop('schema', None) try: single_response_validator(response_definition, context=context) except ValidationError as err: errors = err.detail else: errors = {} assert_path_not_in_errors( 'schema', errors, )