• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python helpers.get_tempstoreclient函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.helpers.get_tempstoreclient函数的典型用法代码示例。如果您正苦于以下问题:Python get_tempstoreclient函数的具体用法?Python get_tempstoreclient怎么用?Python get_tempstoreclient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_get

    def test_get(self):
        client = get_tempstoreclient()
        opbeat = Opbeat(self.app, client=client)
        response = self.client.get('/an-error/?foo=bar')
        self.assertEquals(response.status_code, 500)
        self.assertEquals(len(client.events), 1)

        event = client.events.pop(0)

        self.assertTrue('http' in event)
        http = event['http']
        self.assertEquals(http['url'], 'http://localhost/an-error/')
        self.assertEquals(http['query_string'], 'foo=bar')
        self.assertEquals(http['method'], 'GET')
        self.assertEquals(http['data'], {})
        self.assertTrue('headers' in http)
        headers = http['headers']
        self.assertTrue('Content-Length' in headers, headers.keys())
        self.assertEquals(headers['Content-Length'], '0')
        self.assertTrue('Content-Type' in headers, headers.keys())
        self.assertEquals(headers['Content-Type'], '')
        self.assertTrue('Host' in headers, headers.keys())
        self.assertEquals(headers['Host'], 'localhost')
        env = http['env']
        self.assertTrue('SERVER_NAME' in env, env.keys())
        self.assertEquals(env['SERVER_NAME'], 'localhost')
        self.assertTrue('SERVER_PORT' in env, env.keys())
        self.assertEquals(env['SERVER_PORT'], '80')
开发者ID:anandology,项目名称:opbeat_python,代码行数:28,代码来源:flask_tests.py


示例2: test_post

    def test_post(self):
        client = get_tempstoreclient()
        opbeat = Opbeat(self.app, client=client)
        response = self.client.post('/an-error/?biz=baz', data={'foo': 'bar'})
        self.assertEquals(response.status_code, 500)
        self.assertEquals(len(client.events), 1)

        event = client.events.pop(0)

        self.assertTrue('http' in event)
        http = event['http']
        self.assertEquals(http['url'], 'http://localhost/an-error/')
        self.assertEquals(http['query_string'], 'biz=baz')
        self.assertEquals(http['method'], 'POST')
        self.assertEquals(http['data'], {'foo': 'bar'})
        self.assertTrue('headers' in http)
        headers = http['headers']
        self.assertTrue('Content-Length' in headers, headers.keys())
        self.assertEquals(headers['Content-Length'], '7')
        self.assertTrue('Content-Type' in headers, headers.keys())
        self.assertEquals(headers['Content-Type'], 'application/x-www-form-urlencoded')
        self.assertTrue('Host' in headers, headers.keys())
        self.assertEquals(headers['Host'], 'localhost')
        env = http['env']
        self.assertTrue('SERVER_NAME' in env, env.keys())
        self.assertEquals(env['SERVER_NAME'], 'localhost')
        self.assertTrue('SERVER_PORT' in env, env.keys())
        self.assertEquals(env['SERVER_PORT'], '80')
开发者ID:anandology,项目名称:opbeat_python,代码行数:28,代码来源:flask_tests.py


示例3: test_get_debug

 def test_get_debug(self):
     client = get_tempstoreclient()
     opbeat = Opbeat(self.app, client=client)
     self.app.config['DEBUG'] = True
     self.app.config['TESTING'] = False
     self.assertRaises(ValueError, self.app.test_client().get, '/an-error/?foo=bar')
     self.assertEquals(len(client.events), 0)
开发者ID:patrys,项目名称:opbeat_python,代码行数:7,代码来源:flask_tests.py


示例4: test_call_end_twice

    def test_call_end_twice(self, should_collect, mock_send):
        client = get_tempstoreclient()

        should_collect.return_value = False
        client.begin_transaction("celery")

        client.end_transaction('test-transaction', 200)
        client.end_transaction('test-transaction', 200)
开发者ID:bastih,项目名称:opbeat_python,代码行数:8,代码来源:client_tests.py


示例5: setUp

 def setUp(self):
     self.client = get_tempstoreclient()
     opbeat.instrumentation.control.instrument()
     connection_params = {'host': os.environ.get('MONGODB_HOST', 'localhost'),
                          'port': int(os.environ.get('MONGODB_PORT', 27017))}
     if pymongo.version_tuple < (3, 0):
         connection_params['safe'] = True
     self.mongo = pymongo.MongoClient(**connection_params)
     self.db = self.mongo.opbeat_test
开发者ID:dsanders11,项目名称:opbeat_python,代码行数:9,代码来源:pymongo_tests.py


示例6: setUp

    def setUp(self):
        self._socket_dir = tempfile.mkdtemp(prefix='opbeatzerorpcunittest')
        self._server_endpoint = 'ipc://{0}'.format(os.path.join(
                    self._socket_dir, 'random_zeroserver'
        ))

        self._opbeat = get_tempstoreclient()
        zerorpc.Context.get_instance().register_middleware(OpbeatMiddleware(
                    client=self._opbeat
        ))
开发者ID:ollytheninja,项目名称:opbeat_python,代码行数:10,代码来源:zeropc_tests.py


示例7: test_error_handler

    def test_error_handler(self):
        client = get_tempstoreclient()
        opbeat = Opbeat(self.app, client=client)
        response = self.client.get('/an-error/')
        self.assertEquals(response.status_code, 500)
        self.assertEquals(len(client.events), 1)

        event = client.events.pop(0)

        self.assertTrue('exception' in event)
        exc = event['exception']
        self.assertEquals(exc['type'], 'ValueError')
        self.assertEquals(exc['value'], 'hello world')
        self.assertEquals(event['level'], "error")
        self.assertEquals(event['message'], 'ValueError: hello world')
        self.assertEquals(event['culprit'], 'tests.contrib.flask.flask_tests.an_error')
开发者ID:anandology,项目名称:opbeat_python,代码行数:16,代码来源:flask_tests.py


示例8: setUp

 def setUp(self):
     self.client = get_tempstoreclient()
开发者ID:bastih,项目名称:opbeat_python,代码行数:2,代码来源:client_tests.py


示例9: setUp

 def setUp(self):
     self.client = get_tempstoreclient()
     self.port = random.randint(50000, 60000)
     self.start_test_server()
     opbeat.instrumentation.control.instrument()
开发者ID:dsanders11,项目名称:opbeat_python,代码行数:5,代码来源:urllib3_tests.py


示例10: test_client_kwarg

 def test_client_kwarg(self):
     client = get_tempstoreclient(include_paths=['tests'])
     handler = OpbeatHandler(client=client)
     self.assertEquals(handler.client, client)
开发者ID:patrys,项目名称:opbeat_python,代码行数:4,代码来源:logbook_tests.py


示例11: test_logger

    def test_logger(self):
        client = get_tempstoreclient(include_paths=['tests', 'opbeat'])
        handler = OpbeatHandler(client)
        logger = self.logger

        with handler.applicationbound():
            logger.error('This is a test error')

            self.assertEquals(len(client.events), 1)
            event = client.events.pop(0)
            self.assertEquals(event['logger'], __name__)
            self.assertEquals(event['level'], "error")
            self.assertEquals(event['message'], 'This is a test error')
            self.assertFalse('stacktrace' in event)
            self.assertFalse('exception' in event)
            self.assertTrue('param_message' in event)
            msg = event['param_message']
            self.assertEquals(msg['message'], 'This is a test error')
            self.assertEquals(msg['params'], ())

            logger.warning('This is a test warning')
            self.assertEquals(len(client.events), 1)
            event = client.events.pop(0)
            self.assertEquals(event['logger'], __name__)
            self.assertEquals(event['level'], 'warning')
            self.assertEquals(event['message'], 'This is a test warning')
            self.assertFalse('stacktrace' in event)
            self.assertFalse('exception' in event)
            self.assertTrue('param_message' in event)
            msg = event['param_message']
            self.assertEquals(msg['message'], 'This is a test warning')
            self.assertEquals(msg['params'], ())

            logger.info('This is a test info with a url', extra=dict(
                url='http://example.com',
            ))
            self.assertEquals(len(client.events), 1)
            event = client.events.pop(0)
            self.assertEquals(event['extra']['url'], 'http://example.com')
            self.assertFalse('stacktrace' in event)
            self.assertFalse('exception' in event)
            self.assertTrue('param_message' in event)
            msg = event['param_message']
            self.assertEquals(msg['message'], 'This is a test info with a url')
            self.assertEquals(msg['params'], ())

            try:
                raise ValueError('This is a test ValueError')
            except ValueError:
                logger.info('This is a test info with an exception', exc_info=True)

            self.assertEquals(len(client.events), 1)
            event = client.events.pop(0)

            self.assertEquals(event['message'], 'This is a test info with an exception')
            self.assertTrue('stacktrace' in event)
            self.assertTrue('exception' in event)
            exc = event['exception']
            self.assertEquals(exc['type'], 'ValueError')
            self.assertEquals(exc['value'], 'This is a test ValueError')
            self.assertTrue('param_message' in event)
            msg = event['param_message']
            self.assertEquals(msg['message'], 'This is a test info with an exception')
            self.assertEquals(msg['params'], ())

            # test args
            logger.info('This is a test of %s', 'args')
            self.assertEquals(len(client.events), 1)
            event = client.events.pop(0)
            self.assertEquals(event['message'], 'This is a test of args')
            self.assertFalse('stacktrace' in event)
            self.assertFalse('exception' in event)
            self.assertTrue('param_message' in event)
            msg = event['param_message']
            self.assertEquals(msg['message'], 'This is a test of %s')
            self.assertEquals(msg['params'], ('args',))
开发者ID:patrys,项目名称:opbeat_python,代码行数:76,代码来源:logbook_tests.py


示例12: setUp

 def setUp(self):
     self.client = get_tempstoreclient(include_paths=['tests', 'opbeat'])
     self.handler = OpbeatHandler(self.client)
     self.logger = logging.getLogger(__name__)
     self.logger.handlers = []
     self.logger.addHandler(self.handler)
开发者ID:anandology,项目名称:opbeat_python,代码行数:6,代码来源:logging_tests.py


示例13: setUp

 def setUp(self):
     self.client = get_tempstoreclient()
     opbeat.instrumentation.control.instrument()
开发者ID:KevinEtienne,项目名称:opbeat_python,代码行数:3,代码来源:python_memcached_tests.py


示例14: setUp

    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client()

        self.opbeat_client = get_tempstoreclient()
        self.opbeat = Opbeat(self.app, client=self.opbeat_client)
开发者ID:KevinEtienne,项目名称:opbeat_python,代码行数:6,代码来源:flask_tests.py


示例15: setUp

 def setUp(self):
     self.client = get_tempstoreclient()
     filedir = os.path.dirname(__file__)
     loader = FileSystemLoader(filedir)
     self.env = Environment(loader=loader)
     opbeat.instrumentation.control.instrument()
开发者ID:KevinEtienne,项目名称:opbeat_python,代码行数:6,代码来源:jinja2_tests.py


示例16: setUp

 def setUp(self):
     self.client = get_tempstoreclient()
     self.port = 59990
     self.start_test_server()
     opbeat.instrumentation.control.instrument()
开发者ID:KevinEtienne,项目名称:opbeat_python,代码行数:5,代码来源:urllib3_tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.homogeneous函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.get_package函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap