本文整理汇总了Python中swift.common.wsgi.appconfig函数的典型用法代码示例。如果您正苦于以下问题:Python appconfig函数的具体用法?Python appconfig怎么用?Python appconfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了appconfig函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_run_server_with_latest_eventlet
def test_run_server_with_latest_eventlet(self):
config = """
[DEFAULT]
swift_dir = TEMPDIR
[pipeline:main]
pipeline = proxy-server
[app:proxy-server]
use = egg:swift#proxy
"""
def argspec_stub(server):
return mock.MagicMock(args=["capitalize_response_headers"])
contents = dedent(config)
with temptree(["proxy-server.conf"]) as t:
conf_file = os.path.join(t, "proxy-server.conf")
with open(conf_file, "w") as f:
f.write(contents.replace("TEMPDIR", t))
_fake_rings(t)
with nested(
mock.patch("swift.proxy.server.Application." "modify_wsgi_pipeline"),
mock.patch("swift.common.wsgi.wsgi"),
mock.patch("swift.common.wsgi.eventlet"),
mock.patch("swift.common.wsgi.inspect", getargspec=argspec_stub),
) as (_, _wsgi, _, _):
conf = wsgi.appconfig(conf_file)
logger = logging.getLogger("test")
sock = listen(("localhost", 0))
wsgi.run_server(conf, logger, sock)
_wsgi.server.assert_called()
args, kwargs = _wsgi.server.call_args
self.assertEquals(kwargs.get("capitalize_response_headers"), False)
开发者ID:benjkeller,项目名称:swift,代码行数:35,代码来源:test_wsgi.py
示例2: test_run_server_debug
def test_run_server_debug(self):
config = """
[DEFAULT]
eventlet_debug = yes
client_timeout = 30
max_clients = 1000
swift_dir = TEMPDIR
[pipeline:main]
pipeline = proxy-server
[app:proxy-server]
use = egg:swift#proxy
# while "set" values normally override default
set client_timeout = 20
# this section is not in conf during run_server
set max_clients = 10
"""
contents = dedent(config)
with temptree(['proxy-server.conf']) as t:
conf_file = os.path.join(t, 'proxy-server.conf')
with open(conf_file, 'w') as f:
f.write(contents.replace('TEMPDIR', t))
_fake_rings(t)
with mock.patch('swift.proxy.server.Application.'
'modify_wsgi_pipeline'):
with mock.patch('swift.common.wsgi.wsgi') as _wsgi:
mock_server = _wsgi.server
_wsgi.server = lambda *args, **kwargs: mock_server(
*args, **kwargs)
with mock.patch('swift.common.wsgi.eventlet') as _eventlet:
conf = wsgi.appconfig(conf_file)
logger = logging.getLogger('test')
sock = listen(('localhost', 0))
wsgi.run_server(conf, logger, sock)
self.assertEquals('HTTP/1.0',
_wsgi.HttpProtocol.default_request_version)
self.assertEquals(30, _wsgi.WRITE_TIMEOUT)
_eventlet.hubs.use_hub.assert_called_with(utils.get_hub())
_eventlet.patcher.monkey_patch.assert_called_with(all=False,
socket=True)
_eventlet.debug.hub_exceptions.assert_called_with(True)
self.assertTrue(mock_server.called)
args, kwargs = mock_server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assert_(isinstance(server_app, swift.proxy.server.Application))
self.assertEquals(20, server_app.client_timeout)
self.assertEqual(server_logger, None)
self.assert_('custom_pool' in kwargs)
self.assertEquals(1000, kwargs['custom_pool'].size)
开发者ID:heemanshu,项目名称:swift_juno,代码行数:52,代码来源:test_wsgi.py
示例3: test_run_server_conf_dir
def test_run_server_conf_dir(self):
config_dir = {
'proxy-server.conf.d/pipeline.conf': """
[pipeline:main]
pipeline = proxy-server
""",
'proxy-server.conf.d/app.conf': """
[app:proxy-server]
use = egg:swift#proxy
""",
'proxy-server.conf.d/default.conf': """
[DEFAULT]
eventlet_debug = yes
client_timeout = 30
"""
}
# strip indent from test config contents
config_dir = dict((f, dedent(c)) for (f, c) in config_dir.items())
with temptree(*zip(*config_dir.items())) as conf_root:
conf_dir = os.path.join(conf_root, 'proxy-server.conf.d')
with open(os.path.join(conf_dir, 'swift.conf'), 'w') as f:
f.write('[DEFAULT]\nswift_dir = %s' % conf_root)
_fake_rings(conf_root)
with mock.patch('swift.proxy.server.Application.'
'modify_wsgi_pipeline'):
with mock.patch('swift.common.wsgi.wsgi') as _wsgi:
with mock.patch('swift.common.wsgi.eventlet') as _eventlet:
with mock.patch.dict('os.environ', {'TZ': ''}):
with mock.patch('swift.common.wsgi.inspect'):
conf = wsgi.appconfig(conf_dir)
logger = logging.getLogger('test')
sock = listen(('localhost', 0))
wsgi.run_server(conf, logger, sock)
self.assert_(os.environ['TZ'] is not '')
self.assertEquals('HTTP/1.0',
_wsgi.HttpProtocol.default_request_version)
self.assertEquals(30, _wsgi.WRITE_TIMEOUT)
_eventlet.hubs.use_hub.assert_called_with(utils.get_hub())
_eventlet.patcher.monkey_patch.assert_called_with(all=False,
socket=True)
_eventlet.debug.hub_exceptions.assert_called_with(True)
_wsgi.server.assert_called()
args, kwargs = _wsgi.server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assert_(isinstance(server_app, swift.proxy.server.Application))
self.assert_(isinstance(server_logger, wsgi.NullLogger))
self.assert_('custom_pool' in kwargs)
开发者ID:icorderi,项目名称:swift,代码行数:49,代码来源:test_wsgi.py
示例4: test_run_server
def test_run_server(self):
config = """
[DEFAULT]
client_timeout = 30
max_clients = 1000
swift_dir = TEMPDIR
[pipeline:main]
pipeline = proxy-server
[app:proxy-server]
use = egg:swift#proxy
# while "set" values normally override default
set client_timeout = 20
# this section is not in conf during run_server
set max_clients = 10
"""
contents = dedent(config)
with temptree(["proxy-server.conf"]) as t:
conf_file = os.path.join(t, "proxy-server.conf")
with open(conf_file, "w") as f:
f.write(contents.replace("TEMPDIR", t))
_fake_rings(t)
with mock.patch("swift.proxy.server.Application." "modify_wsgi_pipeline"):
with mock.patch("swift.common.wsgi.wsgi") as _wsgi:
with mock.patch("swift.common.wsgi.eventlet") as _eventlet:
with mock.patch("swift.common.wsgi.inspect"):
conf = wsgi.appconfig(conf_file)
logger = logging.getLogger("test")
sock = listen(("localhost", 0))
wsgi.run_server(conf, logger, sock)
self.assertEquals("HTTP/1.0", _wsgi.HttpProtocol.default_request_version)
self.assertEquals(30, _wsgi.WRITE_TIMEOUT)
_eventlet.hubs.use_hub.assert_called_with(utils.get_hub())
_eventlet.patcher.monkey_patch.assert_called_with(all=False, socket=True)
_eventlet.debug.hub_exceptions.assert_called_with(False)
_wsgi.server.assert_called()
args, kwargs = _wsgi.server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assert_(isinstance(server_app, swift.proxy.server.Application))
self.assertEquals(20, server_app.client_timeout)
self.assert_(isinstance(server_logger, wsgi.NullLogger))
self.assert_("custom_pool" in kwargs)
self.assertEquals(1000, kwargs["custom_pool"].size)
开发者ID:benjkeller,项目名称:swift,代码行数:46,代码来源:test_wsgi.py
示例5: test_run_server_conf_dir
def test_run_server_conf_dir(self):
config_dir = {
"proxy-server.conf.d/pipeline.conf": """
[pipeline:main]
pipeline = proxy-server
""",
"proxy-server.conf.d/app.conf": """
[app:proxy-server]
use = egg:swift#proxy
""",
"proxy-server.conf.d/default.conf": """
[DEFAULT]
client_timeout = 30
""",
}
# strip indent from test config contents
config_dir = dict((f, dedent(c)) for (f, c) in config_dir.items())
with temptree(*zip(*config_dir.items())) as conf_root:
conf_dir = os.path.join(conf_root, "proxy-server.conf.d")
with open(os.path.join(conf_dir, "swift.conf"), "w") as f:
f.write("[DEFAULT]\nswift_dir = %s" % conf_root)
_fake_rings(conf_root)
with mock.patch("swift.proxy.server.Application." "modify_wsgi_pipeline"):
with mock.patch("swift.common.wsgi.wsgi") as _wsgi:
with mock.patch("swift.common.wsgi.eventlet") as _eventlet:
with mock.patch.dict("os.environ", {"TZ": ""}):
with mock.patch("swift.common.wsgi.inspect"):
conf = wsgi.appconfig(conf_dir)
logger = logging.getLogger("test")
sock = listen(("localhost", 0))
wsgi.run_server(conf, logger, sock)
self.assert_(os.environ["TZ"] is not "")
self.assertEquals("HTTP/1.0", _wsgi.HttpProtocol.default_request_version)
self.assertEquals(30, _wsgi.WRITE_TIMEOUT)
_eventlet.hubs.use_hub.assert_called_with(utils.get_hub())
_eventlet.patcher.monkey_patch.assert_called_with(all=False, socket=True)
_eventlet.debug.hub_exceptions.assert_called_with(False)
_wsgi.server.assert_called()
args, kwargs = _wsgi.server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assert_(isinstance(server_app, swift.proxy.server.Application))
self.assert_(isinstance(server_logger, wsgi.NullLogger))
self.assert_("custom_pool" in kwargs)
开发者ID:benjkeller,项目名称:swift,代码行数:45,代码来源:test_wsgi.py
示例6: test_run_server
def test_run_server(self):
config = """
[DEFAULT]
eventlet_debug = yes
client_timeout = 30
swift_dir = TEMPDIR
[pipeline:main]
pipeline = proxy-server
[app:proxy-server]
use = egg:swift#proxy
"""
contents = dedent(config)
with temptree(['proxy-server.conf']) as t:
conf_file = os.path.join(t, 'proxy-server.conf')
with open(conf_file, 'w') as f:
f.write(contents.replace('TEMPDIR', t))
_fake_rings(t)
with patch('swift.common.wsgi.wsgi') as _wsgi:
with patch('swift.common.wsgi.eventlet') as _eventlet:
conf = wsgi.appconfig(conf_file)
logger = logging.getLogger('test')
sock = listen(('localhost', 0))
wsgi.run_server(conf, logger, sock)
self.assertEquals('HTTP/1.0',
_wsgi.HttpProtocol.default_request_version)
self.assertEquals(30, _wsgi.WRITE_TIMEOUT)
_eventlet.hubs.use_hub.assert_called_with(utils.get_hub())
_eventlet.patcher.monkey_patch.assert_called_with(all=False,
socket=True)
_eventlet.debug.hub_exceptions.assert_called_with(True)
_wsgi.server.assert_called()
args, kwargs = _wsgi.server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assert_(isinstance(server_app, swift.proxy.server.Application))
self.assert_(isinstance(server_logger, wsgi.NullLogger))
self.assert_('custom_pool' in kwargs)
开发者ID:ChenZhengtongnju,项目名称:swift,代码行数:40,代码来源:test_wsgi.py
示例7: test_appconfig_dir_ignores_hidden_files
def test_appconfig_dir_ignores_hidden_files(self):
config_dir = {
'server.conf.d/01.conf': """
[app:main]
use = egg:swift#proxy
port = 8080
""",
'server.conf.d/.01.conf.swp': """
[app:main]
use = egg:swift#proxy
port = 8081
""",
}
# strip indent from test config contents
config_dir = dict((f, dedent(c)) for (f, c) in config_dir.items())
with temptree(*zip(*config_dir.items())) as path:
conf_dir = os.path.join(path, 'server.conf.d')
conf = wsgi.appconfig(conf_dir)
expected = {
'__file__': os.path.join(path, 'server.conf.d'),
'here': os.path.join(path, 'server.conf.d'),
'port': '8080',
}
self.assertEquals(conf, expected)
开发者ID:Taejun,项目名称:swift,代码行数:24,代码来源:test_wsgi.py
示例8: test_run_server_with_latest_eventlet
def test_run_server_with_latest_eventlet(self):
config = """
[DEFAULT]
swift_dir = TEMPDIR
[pipeline:main]
pipeline = proxy-server
[app:proxy-server]
use = egg:swift#proxy
"""
def argspec_stub(server):
return mock.MagicMock(args=['capitalize_response_headers'])
contents = dedent(config)
with temptree(['proxy-server.conf']) as t:
conf_file = os.path.join(t, 'proxy-server.conf')
with open(conf_file, 'w') as f:
f.write(contents.replace('TEMPDIR', t))
_fake_rings(t)
with nested(
mock.patch('swift.proxy.server.Application.'
'modify_wsgi_pipeline'),
mock.patch('swift.common.wsgi.wsgi'),
mock.patch('swift.common.wsgi.eventlet'),
mock.patch('swift.common.wsgi.inspect',
getargspec=argspec_stub)) as (_, _wsgi, _, _):
conf = wsgi.appconfig(conf_file)
logger = logging.getLogger('test')
sock = listen(('localhost', 0))
wsgi.run_server(conf, logger, sock)
self.assertTrue(_wsgi.server.called)
args, kwargs = _wsgi.server.call_args
self.assertEquals(kwargs.get('capitalize_response_headers'), False)
开发者ID:heemanshu,项目名称:swift_juno,代码行数:36,代码来源:test_wsgi.py
注:本文中的swift.common.wsgi.appconfig函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论