当前位置: 首页>>代码示例>>Python>>正文


Python config.setup_config函数代码示例

本文整理汇总了Python中ramlfications.config.setup_config函数的典型用法代码示例。如果您正苦于以下问题:Python setup_config函数的具体用法?Python setup_config怎么用?Python setup_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setup_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_no_config_file_found

def test_no_config_file_found():
    config_file = "/tmp/a-nonexistent-RAML-config-file.ini"
    with pytest.raises(IOError) as e:
        setup_config(config_file)

    msg = ("No such file or directory: '{0}'".format(config_file),)
    assert e.value.args == msg
开发者ID:adamchainz,项目名称:ramlfications,代码行数:7,代码来源:test_config.py

示例2: validate

def validate(raml, config_file=None):
    """
    Module helper function to validate a RAML File.  First loads \
    the RAML file \
    with :py:class:`.loader.RAMLLoader` then validates with \
    :py:func:`.validate.validate_raml`.

    :param str raml: Either string path to the RAML file, a file object, \or
        a string representation of RAML.
    :param str config_file:  String path to desired config file, if any.
    :return: No return value if successful
    :raises LoadRAMLError: If error occurred trying to load the RAML file
        (see :py:class:`.loader.RAMLLoader`)
    :raises InvalidRootNodeError: API metadata is invalid according to RAML \
        `specification <http://raml.org/spec.html>`_.
    :raises InvalidResourceNodeError: API resource endpoint is invalid \
        according to RAML `specification <http://raml.org/spec.html>`_.
    :raises InvalidParameterError: Named parameter is invalid \
        according to RAML `specification <http://raml.org/spec.html>`_.
    :raises InvalidRAMLError: RAML file is invalid according to RAML \
        `specification <http://raml.org/spec.html>`_.
    """
    loader = load(raml)
    config = setup_config(config_file)
    config["validate"] = True
    parse_raml(loader, config)
开发者ID:jenner,项目名称:ramlfications,代码行数:26,代码来源:__init__.py

示例3: test_resource_type_empty_mapping_headers

def test_resource_type_empty_mapping_headers():
    raml_file = os.path.join(EXAMPLES + "empty-mapping.raml")
    loaded_raml_file = load_file(raml_file)
    config = setup_config(EXAMPLES + "test-config.ini")
    config['validate'] = False
    api = pw.parse_raml(loaded_raml_file, config)

    base_res_type = api.resource_types[0]

    assert len(base_res_type.headers) == 3
    assert base_res_type.headers[-1].description is None
开发者ID:AndreasBackx,项目名称:ramlfications,代码行数:11,代码来源:test_parser.py

示例4: test_resource_response_no_desc

def test_resource_response_no_desc():
    raml_file = os.path.join(EXAMPLES + "empty-mapping.raml")
    loaded_raml_file = load_file(raml_file)
    config = setup_config(EXAMPLES + "test-config.ini")
    config['validate'] = False
    api = pw.parse_raml(loaded_raml_file, config)

    res = api.resources[-1]
    response = res.responses[-1]

    assert response.code == 204
    assert response.description is None
开发者ID:AndreasBackx,项目名称:ramlfications,代码行数:12,代码来源:test_parser.py

示例5: test_resource_type_empty_mapping

def test_resource_type_empty_mapping():
    raml_file = os.path.join(EXAMPLES + "empty-mapping-resource-type.raml")
    loaded_raml_file = load_file(raml_file)
    config = setup_config(EXAMPLES + "test-config.ini")
    config['validate'] = False
    api = pw.parse_raml(loaded_raml_file, config)

    assert len(api.resource_types) == 1

    res = api.resource_types[0]

    assert res.name == "emptyType"
    assert res.raw == {}
开发者ID:AndreasBackx,项目名称:ramlfications,代码行数:13,代码来源:test_parser.py

示例6: test_config_file

def test_config_file(config, basic_config):
    bc = basic_config  # lazy
    bc["resp_codes"] = _clean(bc["resp_codes"] + [420, 421, 422])
    bc["auth_schemes"] = _clean(
        bc["auth_schemes"] + ["oauth_3_0", "oauth_4_0"]
    )
    bc["media_types"] = _clean(
        bc["media_types"] + ["application/vnd.github.v3", "foo/bar"]
    )
    bc["protocols"] = _clean(bc["protocols"] + ["FTP"])
    bc["raml_versions"] = _clean(bc["raml_versions"] + ["0.8"])
    bc["production"] = 'True'
    bc["validate"] = 'True'

    parsed_config = setup_config(config)

    assert _dict_equal(bc, parsed_config)
开发者ID:adamchainz,项目名称:ramlfications,代码行数:17,代码来源:test_config.py

示例7: validate

def validate(raml, config_file=None):
    """
    Module helper function to validate a RAML File.  First loads \
    the RAML file \
    with :py:class:`.loader.RAMLLoader` then validates with \
    :py:func:`.validate.validate_raml`.

    :param str raml: Either string path to the RAML file, a file object, \or
        a string representation of RAML.
    :param str config_file:  String path to desired config file, if any.
    :return: No return value if successful
    :raises LoadRAMLError: If error occurred trying to load the RAML file
        (see :py:class:`.loader.RAMLLoader`)
    :raises InvalidRamlFileError: If error occurred trying to validate the RAML
        file (see :py:mod:`.validate`)

    """
    loader = load(raml)
    config = setup_config(config_file)
    config["validate"] = True
    parse_raml(loader, config)
开发者ID:postatum,项目名称:ramlfications,代码行数:21,代码来源:__init__.py

示例8: parse

def parse(raml, config_file=None):
    """
    Module helper function to parse a RAML File.  First loads the RAML file
    with :py:class:`.loader.RAMLLoader` then parses with
    :py:func:`.parser.parse_raml` to return a :py:class:`.raml.RAMLRoot`
    object.

    :param raml: Either string path to the RAML file, a file object, or \
        a string representation of RAML.
    :param str config_file:  String path to desired config file, if any.
    :return: parsed API
    :rtype: RAMLRoot
    :raises LoadRAMLError: If error occurred trying to load the RAML file
        (see :py:class:`.loader.RAMLLoader`)
    :raises RAMLParserError: If error occurred during parsing of RAML file
        (see :py:class:`.raml.RAMLRoot`)
    :raises InvalidRamlFileError: RAML file is invalid according to RAML \
        `specification <http://raml.org/spec.html>`_.
    """
    loader = load(raml)
    config = setup_config(config_file)
    return parse_raml(loader, config)
开发者ID:postatum,项目名称:ramlfications,代码行数:22,代码来源:__init__.py

示例9: load_config

def load_config(filename):
    config_file = os.path.join(VALIDATE + filename)
    return setup_config(config_file)
开发者ID:econchick,项目名称:ramlfications,代码行数:3,代码来源:test_validate.py

示例10: uri_param_resources

def uri_param_resources():
    raml_file = os.path.join(EXAMPLES, "preserve-uri-order.raml")
    loaded_raml = load_file(raml_file)
    config = setup_config(EXAMPLES + "test-config.ini")
    config['validate'] = False
    return pw.parse_raml(loaded_raml, config)
开发者ID:AndreasBackx,项目名称:ramlfications,代码行数:6,代码来源:test_parser.py

示例11: test_no_config_file_given

def test_no_config_file_given(basic_config):
    parsed_config = setup_config(config_file=None)
    assert parsed_config == basic_config
开发者ID:adamchainz,项目名称:ramlfications,代码行数:3,代码来源:test_config.py

示例12: inherited_resources

def inherited_resources():
    raml_file = os.path.join(EXAMPLES, "resource-type-inherited.raml")
    loaded_raml = load_file(raml_file)
    config = setup_config(EXAMPLES + "test-config.ini")
    config["validate"] = False
    return pw.parse_raml(loaded_raml, config)
开发者ID:AndreasBackx,项目名称:ramlfications,代码行数:6,代码来源:test_parser.py

示例13: external_resource_with_multiple_methods

def external_resource_with_multiple_methods():
    raml_file = os.path.join(
        EXAMPLES + "external_resource_with_multiple_methods.raml")
    loaded_raml_file = load_file(raml_file)
    config = setup_config(EXAMPLES + "test-config.ini")
    return pw.parse_raml(loaded_raml_file, config)
开发者ID:bpowell65536,项目名称:ramlfications,代码行数:6,代码来源:test_parser.py

示例14: resources

def resources():
    raml_file = os.path.join(EXAMPLES + "complete-valid-example.raml")
    loaded_raml_file = load_file(raml_file)
    config = setup_config(EXAMPLES + "test-config.ini")
    api = pw.parse_raml(loaded_raml_file, config)
    return api.resources
开发者ID:AndreasBackx,项目名称:ramlfications,代码行数:6,代码来源:test_parser.py

示例15: test_parse_raml

def test_parse_raml(loaded_raml):
    config = setup_config(EXAMPLES + "test-config.ini")
    root = pw.parse_raml(loaded_raml, config)
    assert isinstance(root, RootNode)
开发者ID:AndreasBackx,项目名称:ramlfications,代码行数:4,代码来源:test_parser.py


注:本文中的ramlfications.config.setup_config函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。