本文整理汇总了Python中mock.NonCallableMock.proxy_connection_pool方法的典型用法代码示例。如果您正苦于以下问题:Python NonCallableMock.proxy_connection_pool方法的具体用法?Python NonCallableMock.proxy_connection_pool怎么用?Python NonCallableMock.proxy_connection_pool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.NonCallableMock
的用法示例。
在下文中一共展示了NonCallableMock.proxy_connection_pool方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mock_auctions_server
# 需要导入模块: from mock import NonCallableMock [as 别名]
# 或者: from mock.NonCallableMock import proxy_connection_pool [as 别名]
def mock_auctions_server(request, mocker):
params = getattr(request, 'param', {})
server_config_redis = params.get('server_config_redis', DEFAULT)
connection_limit = params.get('connection_limit', DEFAULT)
get_mapping = params.get('get_mapping', DEFAULT)
proxy_path = params.get('proxy_path', DEFAULT)
event_sources_pool = params.get('event_sources_pool', DEFAULT)
proxy_connection_pool = params.get('proxy_connection_pool', DEFAULT)
stream_proxy = params.get('stream_proxy', DEFAULT)
db = params.get('db', DEFAULT)
request_headers = params.get('request_headers', [])
request_url = params.get('request_url', DEFAULT)
redirect_url = params.get('redirect_url', DEFAULT)
abort = params.get('abort', DEFAULT)
class AuctionsServerAttributesContainer(object):
logger = NotImplemented
proxy_mappings = NotImplemented
config = NotImplemented
event_sources_pool = NotImplemented
proxy_connection_pool = NotImplemented
get_mapping = NotImplemented
db = NotImplemented
request_headers = NotImplemented
class Request(object):
headers = NotImplemented
environ = NotImplemented
url = NotImplemented
class Config(object):
__getitem__ = NotImplemented
def config_getitem(item):
if item == 'REDIS':
return server_config_redis
elif item == 'event_source_connection_limit':
return connection_limit
else:
raise KeyError
mock_path_info = MagicMock()
def environ_setitem(item, value):
if item == 'PATH_INFO':
mock_path_info(value)
return value
else:
raise KeyError
mocker.patch.object(auctions_server_module, 'get_mapping', get_mapping)
patch_pysse = mocker.patch.object(auctions_server_module, 'PySse',
spec_set=PySse)
patch_add_message = patch_pysse.return_value.add_message
patch_request = mocker.patch.object(auctions_server_module, 'request',
spec_set=Request)
patch_request.environ.__setitem__.side_effect = environ_setitem
patch_request.headers = request_headers
patch_request.url = request_url
patch_redirect = mocker.patch.object(auctions_server_module, 'redirect',
return_value=redirect_url)
patch_abort = mocker.patch.object(auctions_server_module, 'abort',
return_value=abort)
patch_StreamProxy = \
mocker.patch.object(auctions_server_module, 'StreamProxy',
return_value=stream_proxy)
auctions_server = NonCallableMock(spec_set=
AuctionsServerAttributesContainer)
logger = MagicMock(spec_set=frontend.logger)
proxy_mappings = MagicMock(spec_set=Memoizer({}))
proxy_mappings.get.return_value = proxy_path
config = MagicMock(spec_set=Config)
config.__getitem__.side_effect = config_getitem
auctions_server.logger = logger
auctions_server.proxy_mappings = proxy_mappings
auctions_server.config = config
auctions_server.event_sources_pool = event_sources_pool
auctions_server.proxy_connection_pool = proxy_connection_pool
auctions_server.db = db
mocker.patch.object(auctions_server_module, 'auctions_server',
auctions_server)
return {'server': auctions_server,
'proxy_mappings': proxy_mappings,
'mock_path_info': mock_path_info,
'patch_StreamProxy': patch_StreamProxy,
'patch_redirect': patch_redirect,
'patch_abort': patch_abort,
'patch_PySse': patch_pysse,
'patch_add_message': patch_add_message}