當前位置: 首頁>>代碼示例>>Python>>正文


Python mox.IgnoreArg方法代碼示例

本文整理匯總了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() 
開發者ID:google,項目名稱:macops,代碼行數:26,代碼來源:certs_test.py

示例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() 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:21,代碼來源:server_test.py

示例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)) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:25,代碼來源:server_test.py

示例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() 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:25,代碼來源:server_test.py

示例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() 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:19,代碼來源:server_test.py

示例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() 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:23,代碼來源:server_test.py

示例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() 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:25,代碼來源:server_test.py

示例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() 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:18,代碼來源:dispatcher_test.py

示例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) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:22,代碼來源:dispatcher_test.py

示例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() 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:19,代碼來源:static_files_handler_test.py

示例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() 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:19,代碼來源:static_files_handler_test.py

示例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 
開發者ID:tellapart,項目名稱:aurproxy,代碼行數:21,代碼來源:aurora.py

示例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() 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:21,代碼來源:module_test.py

示例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)) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:22,代碼來源:module_test.py

示例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)) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:25,代碼來源:module_test.py


注:本文中的mox.IgnoreArg方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。