当前位置: 首页>>代码示例>>Python>>正文


Python Client.close方法代码示例

本文整理汇总了Python中opbeat.base.Client.close方法的典型用法代码示例。如果您正苦于以下问题:Python Client.close方法的具体用法?Python Client.close怎么用?Python Client.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opbeat.base.Client的用法示例。


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

示例1: test_send_remote_failover_async

# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import close [as 别名]
    def test_send_remote_failover_async(self, should_try, http_send):
        should_try.return_value = True

        client = Client(
            servers=['http://example.com'],
            organization_id='organization_id',
            app_id='app_id',
            secret_token='secret',
            async_mode=True,
        )
        logger = mock.Mock()
        client.error_logger.error = logger

        # test error
        encoded_data = client.encode({'message': 'oh no'})
        http_send.side_effect = TransportException('oopsie', encoded_data)
        client.send_remote('http://example.com/api/store', data=encoded_data)
        client.close()
        assert client.state.status == client.state.ERROR
        assert len(logger.call_args_list) == 2
        assert 'oopsie' in logger.call_args_list[0][0][0]
        assert 'oh no' in logger.call_args_list[1][0][1]

        # test recovery
        http_send.side_effect = None
        client.send_remote('http://example.com/api/store', 'foo')
        client.close()
        assert client.state.status == client.state.ONLINE
开发者ID:bastih,项目名称:opbeat_python,代码行数:30,代码来源:client_tests.py

示例2: test_client_shutdown_async

# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import close [as 别名]
 def test_client_shutdown_async(self, mock_traces_collect, mock_send):
     client = Client(
         servers=["http://example.com"],
         organization_id="organization_id",
         app_id="app_id",
         secret_token="secret",
         async_mode=True,
     )
     client.send(auth_header="foo", **{"foo": "bar"})
     client.close()
     self.assertEqual(mock_traces_collect.call_count, 1)
     self.assertEqual(mock_send.call_count, 1)
开发者ID:opbeat,项目名称:opbeat_python,代码行数:14,代码来源:client_tests.py

示例3: test_client_shutdown_async

# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import close [as 别名]
 def test_client_shutdown_async(self, mock_traces_collect, mock_send):
     client = Client(
         servers=['http://example.com'],
         organization_id='organization_id',
         app_id='app_id',
         secret_token='secret',
         async_mode=True,
     )
     client.send(auth_header='foo', **{
         'foo': 'bar',
     })
     client.close()
     self.assertEqual(mock_traces_collect.call_count, 1)
     self.assertEqual(mock_send.call_count, 1)
开发者ID:bastih,项目名称:opbeat_python,代码行数:16,代码来源:client_tests.py

示例4: test_send_remote_failover_async

# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import close [as 别名]
    def test_send_remote_failover_async(self, should_try, send_remote):
        should_try.return_value = True

        client = Client(
            servers=['http://example.com'],
            organization_id='organization_id',
            app_id='app_id',
            secret_token='secret',
            async=True,
        )

        # test error
        send_remote.side_effect = Exception()
        client.send_remote('http://example.com/api/store', 'foo')
        client.close()
        self.assertEquals(client.state.status, client.state.ERROR)

        # test recovery
        send_remote.side_effect = None
        client.send_remote('http://example.com/api/store', 'foo')
        client.close()
        self.assertEquals(client.state.status, client.state.ONLINE)
开发者ID:patrys,项目名称:opbeat_python,代码行数:24,代码来源:client_tests.py


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