Exemple #1
0
def test_convert_parser_lazy_swagger_backend():
    from prance import BaseParser, ResolvingParser, ValidationError
    parser = BaseParser('tests/specs/petstore.yaml')

    # Conversion should fail with the default backend.
    with pytest.raises(ValidationError):
        converted = convert.convert_spec(parser)

    # However, with the lazy flag it should work.
    converted = convert.convert_spec(parser, lazy=True)
    assert isinstance(converted, BaseParser)

    # Passing a ResolvingParser class should also work.
    converted = convert.convert_spec(parser, ResolvingParser, lazy=True)
    assert isinstance(converted, ResolvingParser)
Exemple #2
0
  def test_convert_parser_validated():
    from prance import BaseParser
    parser = BaseParser('tests/specs/petstore.yaml', backend = 'openapi-spec-validator')

    # Conversion should work: it's the right backend, and it validates.
    converted = convert.convert_spec(parser)
    assert isinstance(converted, BaseParser)
    assert converted.version_parsed[0] == 3