本文整理汇总了Python中mox.IgnoreArg方法的典型用法代码示例。如果您正苦于以下问题:Python mox.IgnoreArg方法的具体用法?Python mox.IgnoreArg怎么用?Python mox.IgnoreArg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mox
的用法示例。
在下文中一共展示了mox.IgnoreArg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testInstallCertInKeychainPrivateFailNoPassNoApp
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def testInstallCertInKeychainPrivateFailNoPassNoApp(self):
"""Test InstallCertInKeychain private key failure, no pass or app."""
self.StubSetup()
certs.tempfile.mkdtemp(prefix=mox.IgnoreArg()).AndReturn('tempdir')
mock_file = self.mox.CreateMockAnything()
open('tempdir/private.key', 'w').AndReturn(mock_file)
mock_file.write('key').AndReturn(None)
mock_file.close().AndReturn(None)
certs.logging.info('Installing downloaded key into the %s keychain',
'k').AndReturn(None)
command = [certs.CMD_SECURITY, 'import', 'tempdir/private.key', '-x',
'-k', 'k', '-A']
certs.logging.debug('Command: %s', command).AndReturn(None)
certs.gmacpyutil.RunProcess(command,
sudo=False,
sudo_password=None).AndReturn(('out', 'err', 1))
certs.logging.debug('Private key installation output: %s',
'out').AndReturn(None)
certs.shutil.rmtree('tempdir').AndReturn(None)
self.mox.ReplayAll()
self.assertRaises(certs.KeychainError, certs.InstallCertInKeychain, 'cert',
'key', keychain='k')
self.mox.VerifyAll()
示例2: test_warmup
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_warmup(self):
s = AutoScalingServerFacade(balanced_port=8080)
self.mox.StubOutWithMock(s, '_handle_request')
self.mox.StubOutWithMock(s._condition, 'notify')
inst = self.mox.CreateMock(instance.Instance)
environ = object()
s.build_request_environ('GET', '/_ah/warmup', [], '', '0.1.0.3', 8080,
fake_login=True).AndReturn(environ)
s._handle_request(environ,
mox.IgnoreArg(),
inst=inst,
request_type=instance.READY_REQUEST)
s._condition.notify(1)
self.mox.ReplayAll()
s._warmup(inst)
self.mox.VerifyAll()
示例3: test_handle_cannot_accept_request
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_handle_cannot_accept_request(self):
self.auto_server._choose_instance(0.1).AndReturn(self.inst)
self.auto_server._choose_instance(0.1).AndReturn(self.inst)
self.inst.handle(
self.environ, self.start_response, self.url_map, self.match,
self.request_id, instance.NORMAL_REQUEST).AndRaise(
instance.CannotAcceptRequests)
self.inst.handle(
self.environ, self.start_response, self.url_map, self.match,
self.request_id, instance.NORMAL_REQUEST).AndReturn(
self.response)
self.mox.ReplayAll()
self.assertEqual(
self.response,
self.auto_server._handle_script_request(self.environ,
self.start_response,
self.url_map,
self.match,
self.request_id))
self.mox.VerifyAll()
self.assertEqual([(mox.IgnoreArg(), 1)],
list(self.auto_server._outstanding_request_history))
示例4: test_instance_start_success
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_instance_start_success(self):
s = ManualScalingServerFacade(balanced_port=8080)
self.mox.StubOutWithMock(s, '_handle_request')
self.mox.StubOutWithMock(s._condition, 'notify')
wsgi_servr = self.mox.CreateMock(wsgi_server.WsgiServer)
wsgi_servr.port = 12345
inst = self.mox.CreateMock(instance.Instance)
inst.instance_id = 0
inst.start().AndReturn(True)
environ = object()
s.build_request_environ('GET', '/_ah/start', [], '', '0.1.0.3', 12345,
fake_login=True).AndReturn(environ)
s._handle_request(environ,
mox.IgnoreArg(),
inst=inst,
request_type=instance.READY_REQUEST)
s._condition.notify(1)
self.mox.ReplayAll()
s._start_instance(wsgi_servr, inst)
self.mox.VerifyAll()
示例5: test_send_interactive_command
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_send_interactive_command(self):
def good_response(unused_environ, start_response, request_type):
start_response('200 OK', [])
return ['10\n']
environ = object()
self.servr.build_request_environ(
'POST', '/', [], 'print 5+5', '192.0.2.0', 8000).AndReturn(environ)
self.servr._handle_request(
environ,
mox.IgnoreArg(),
request_type=instance.INTERACTIVE_REQUEST).WithSideEffects(
good_response)
self.mox.ReplayAll()
self.assertEqual('10\n', self.servr.send_interactive_command('print 5+5'))
self.mox.VerifyAll()
示例6: test_handle_script_request
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_handle_script_request(self):
self.servr._instance_factory.new_instance(
mox.IgnoreArg(),
expect_ready_request=False).AndReturn(self.inst)
self.inst.start()
self.inst.handle(self.environ,
self.start_response,
self.url_map,
self.match,
self.request_id,
instance.INTERACTIVE_REQUEST).AndReturn(['10\n'])
self.mox.ReplayAll()
self.assertEqual(
['10\n'],
self.servr._handle_script_request(self.environ,
self.start_response,
self.url_map,
self.match,
self.request_id))
self.mox.VerifyAll()
示例7: test_handle_script_request_unexpected_instance_exception
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_handle_script_request_unexpected_instance_exception(self):
self.servr._instance_factory.new_instance(
mox.IgnoreArg(),
expect_ready_request=False).AndReturn(self.inst)
self.inst.start()
self.inst.handle(
self.environ,
self.start_response,
self.url_map,
self.match,
self.request_id,
instance.INTERACTIVE_REQUEST).AndRaise(httplib.BadStatusLine('line'))
self.mox.ReplayAll()
self.assertRaises(
httplib.BadStatusLine,
self.servr._handle_script_request,
self.environ,
self.start_response,
self.url_map,
self.match,
self.request_id)
self.mox.VerifyAll()
示例8: test_add_async_request
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_add_async_request(self):
dummy_environ = object()
self.mox.StubOutWithMock(dispatcher._THREAD_POOL, 'submit')
self.dispatcher._server_name_to_server['default'].build_request_environ(
'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],
'body', '1.2.3.4', 1).AndReturn(
dummy_environ)
dispatcher._THREAD_POOL.submit(
self.dispatcher._handle_request, dummy_environ, mox.IgnoreArg(),
self.dispatcher._server_name_to_server['default'],
None, catch_and_log_exceptions=True)
self.mox.ReplayAll()
self.dispatcher.add_async_request(
'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],
'body', '1.2.3.4')
self.mox.VerifyAll()
示例9: test_add_request
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_add_request(self):
dummy_environ = object()
self.mox.StubOutWithMock(self.dispatcher, '_resolve_target')
self.mox.StubOutWithMock(self.dispatcher, '_handle_request')
self.dispatcher._resolve_target(None, '/foo').AndReturn(
(self.dispatcher._server_name_to_server['default'], None))
self.dispatcher._server_name_to_server['default'].build_request_environ(
'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],
'body', '1.2.3.4', 1, fake_login=True).AndReturn(
dummy_environ)
self.dispatcher._handle_request(
dummy_environ, mox.IgnoreArg(),
self.dispatcher._server_name_to_server['default'],
None).AndReturn(['Hello World'])
self.mox.ReplayAll()
response = self.dispatcher.add_request(
'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],
'body', '1.2.3.4', fake_login=True)
self.mox.VerifyAll()
self.assertEqual('Hello World', response.content)
示例10: test_simple_path
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_simple_path(self):
url_map = appinfo.URLMap(url='/',
static_files='index.html')
h = static_files_handler.StaticFilesHandler(root_path='/appdir',
url_map=url_map)
match = h.match('/')
self.assertTrue(match)
self.assertFalse(h.match('/other'))
static_files_handler.StaticContentHandler._handle_path(
os.path.join('/appdir', 'index.html'),
{},
mox.IgnoreArg()).AndReturn('<output>')
self.mox.ReplayAll()
self.assertEqual('<output>',
h.handle(match, {}, None))
self.mox.VerifyAll()
示例11: test_patterned_path
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_patterned_path(self):
url_map = appinfo.URLMap(url=r'/(.*)/(.*)',
static_files=r'static/\1/subdir/\2')
h = static_files_handler.StaticFilesHandler(root_path='/appdir',
url_map=url_map)
match = h.match('/hello/foo.jpg')
self.assertTrue(match)
self.assertFalse(h.match('/'))
static_files_handler.StaticContentHandler._handle_path(
os.path.join('/appdir', 'static/hello/subdir/foo.jpg'),
{},
mox.IgnoreArg()).AndReturn('<output>')
self.mox.ReplayAll()
self.assertEqual('<output>',
h.handle(match, {}, None))
self.mox.VerifyAll()
示例12: getMockServerSet
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def getMockServerSet(smox):
listeners = []
def add_listener(listener):
listeners.append(listener)
zk = smox.CreateMock(KazooClient)
zk.connected = True
zk.handler = SequentialGeventHandler()
zk.retry = KazooRetry()
mock_stat = smox.CreateMock(ZnodeStat)
mock_stat.mzxid = 1
zk.exists(TEST_PATH).AndReturn(True)
zk.add_listener(mox.IgnoreArg()).WithSideEffects(add_listener)
zk.get(TEST_PATH, mox.IgnoreArg()).AndReturn((1, mock_stat))
zk.add_listener(mox.IgnoreArg()).WithSideEffects(add_listener)
return zk
示例13: test_warmup
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_warmup(self):
s = AutoScalingModuleFacade(balanced_port=8080)
self.mox.StubOutWithMock(s, '_handle_request')
self.mox.StubOutWithMock(s._condition, 'notify')
inst = self.mox.CreateMock(instance.Instance)
environ = object()
s.build_request_environ('GET', '/_ah/warmup', [], '', '0.1.0.3', 8080,
fake_login=True).AndReturn(environ)
s._handle_request(environ,
mox.IgnoreArg(),
inst=inst,
request_type=instance.READY_REQUEST)
s._condition.notify(1)
self.mox.ReplayAll()
s._warmup(inst)
self.mox.VerifyAll()
示例14: test_handle_script_request
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_handle_script_request(self):
self.auto_module._choose_instance(0.1).AndReturn(self.inst)
self.inst.handle(self.environ,
self.start_response,
self.url_map,
self.match,
self.request_id,
instance.NORMAL_REQUEST).AndReturn(self.response)
self.mox.ReplayAll()
self.assertEqual(
self.response,
self.auto_module._handle_script_request(self.environ,
self.start_response,
self.url_map,
self.match,
self.request_id))
self.mox.VerifyAll()
self.assertEqual([(mox.IgnoreArg(), 1)],
list(self.auto_module._outstanding_request_history))
示例15: test_handle_cannot_accept_request
# 需要导入模块: import mox [as 别名]
# 或者: from mox import IgnoreArg [as 别名]
def test_handle_cannot_accept_request(self):
self.auto_module._choose_instance(0.1).AndReturn(self.inst)
self.auto_module._choose_instance(0.1).AndReturn(self.inst)
self.inst.handle(
self.environ, self.start_response, self.url_map, self.match,
self.request_id, instance.NORMAL_REQUEST).AndRaise(
instance.CannotAcceptRequests)
self.inst.handle(
self.environ, self.start_response, self.url_map, self.match,
self.request_id, instance.NORMAL_REQUEST).AndReturn(
self.response)
self.mox.ReplayAll()
self.assertEqual(
self.response,
self.auto_module._handle_script_request(self.environ,
self.start_response,
self.url_map,
self.match,
self.request_id))
self.mox.VerifyAll()
self.assertEqual([(mox.IgnoreArg(), 1)],
list(self.auto_module._outstanding_request_history))