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


Python StackInABox.update_uri方法代码示例

本文整理汇总了Python中stackinabox.stack.StackInABox.update_uri方法的典型用法代码示例。如果您正苦于以下问题:Python StackInABox.update_uri方法的具体用法?Python StackInABox.update_uri怎么用?Python StackInABox.update_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stackinabox.stack.StackInABox的用法示例。


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

示例1: registration

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import update_uri [as 别名]
def registration(uri):
    """Responses handler registration.

    Registers a handler for a given URI with Responses
    so that it can be intercepted and handed to
    Stack-In-A-Box.

    :param uri: URI used for the base of the HTTP requests

    :returns: n/a
    """

    # log the URI that is used to access the Stack-In-A-Box services
    logger.debug('Registering Stack-In-A-Box at {0} under Python Responses'
                 .format(uri))
    # tell Stack-In-A-Box what URI to match with
    StackInABox.update_uri(uri)

    # Build the regex for the URI and register all HTTP verbs
    # with Responses
    regex = re.compile('(http)?s?(://)?{0}:?(\d+)?/'.format(uri),
                       re.I)
    METHODS = [
        responses.DELETE,
        responses.GET,
        responses.HEAD,
        responses.OPTIONS,
        responses.PATCH,
        responses.POST,
        responses.PUT
    ]
    for method in METHODS:
        responses.add_callback(method,
                               regex,
                               callback=responses_callback)
开发者ID:BenjamenMeyer,项目名称:stackInABox,代码行数:37,代码来源:core.py

示例2: requests_mock_session_registration

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import update_uri [as 别名]
def requests_mock_session_registration(uri, session):
    logger.debug('Registering Stack-In-A-Box at {0} under Python Requests-Mock'
                 .format(uri))
    logger.debug('Session has id {0}'.format(id(session)))

    StackInABox.update_uri(uri)
    StackInABox.hold_onto('adapter', requests_mock.Adapter())
    StackInABox.hold_out('adapter').add_matcher(RequestMockCallable(uri))

    session.mount('http://{0}'.format(uri), StackInABox.hold_out('adapter'))
    session.mount('https://{0}'.format(uri), StackInABox.hold_out('adapter'))
开发者ID:kidster,项目名称:stackInABox,代码行数:13,代码来源:util_requests_mock.py

示例3: httpretty_registration

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import update_uri [as 别名]
def httpretty_registration(uri):

    status_data = {
        595: 'StackInABoxService - Unknown Route',
        596: 'StackInABox - Exception in Service Handler',
        597: 'StackInABox - Unknown Service'
    }
    for k, v in six.iteritems(status_data):
        if k not in httpretty.http.STATUSES:
            httpretty.http.STATUSES[k] = v

    logger.debug('Registering Stack-In-A-Box at {0} under Python HTTPretty'
                 .format(uri))
    StackInABox.update_uri(uri)
    regex = re.compile('(http)?s?(://)?{0}:?(\d+)?/'.format(uri),
                       re.I)
    for method in HttpBaseClass.METHODS:
        register_uri(method, regex, body=httpretty_callback)
开发者ID:kidster,项目名称:stackInABox,代码行数:20,代码来源:util_httpretty.py

示例4: responses_registration

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import update_uri [as 别名]
def responses_registration(uri):
    logger.debug('Registering Stack-In-A-Box at {0} under Python Responses'
                 .format(uri))
    StackInABox.update_uri(uri)
    regex = re.compile('(http)?s?(://)?{0}:?(\d+)?/'.format(uri),
                       re.I)
    METHODS = [
        responses.DELETE,
        responses.GET,
        responses.HEAD,
        responses.OPTIONS,
        responses.PATCH,
        responses.POST,
        responses.PUT
    ]
    for method in METHODS:
        responses.add_callback(method,
                               regex,
                               callback=responses_callback)
开发者ID:kidster,项目名称:stackInABox,代码行数:21,代码来源:util_responses.py

示例5: session_registration

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import update_uri [as 别名]
def session_registration(uri, session):
    """Requests-mock registration with a specific Session.

    :param uri: base URI to match against
    :param session: Python requests' Session object

    :returns: n/a
    """
    # log the URI that is used to access the Stack-In-A-Box services
    logger.debug('Registering Stack-In-A-Box at {0} under Python Requests-Mock'
                 .format(uri))
    logger.debug('Session has id {0}'.format(id(session)))

    # tell Stack-In-A-Box what URI to match with
    StackInABox.update_uri(uri)

    # Create a Python Requests Adapter object for handling the session
    StackInABox.hold_onto('adapter', requests_mock.Adapter())
    # Add the Request handler object for the URI
    StackInABox.hold_out('adapter').add_matcher(RequestMockCallable(uri))

    # Tell the session about the adapter and the URI
    session.mount('http://{0}'.format(uri), StackInABox.hold_out('adapter'))
    session.mount('https://{0}'.format(uri), StackInABox.hold_out('adapter'))
开发者ID:BenjamenMeyer,项目名称:stackInABox,代码行数:26,代码来源:core.py


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