本文整理汇总了Python中opbeat.base.Client.send方法的典型用法代码示例。如果您正苦于以下问题:Python Client.send方法的具体用法?Python Client.send怎么用?Python Client.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opbeat.base.Client
的用法示例。
在下文中一共展示了Client.send方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_client_shutdown_async
# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import send [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)
示例2: test_send_not_enabled
# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import send [as 别名]
def test_send_not_enabled(self, time, send_remote):
time.return_value = 1328055286.51
with mock.patch.dict("os.environ", {"OPBEAT_DISABLE_SEND": "true"}):
client = Client(
servers=["http://example.com"],
organization_id="organization_id",
app_id="app_id",
secret_token="secret",
)
client.send(**{"foo": "bar"})
assert not send_remote.called
示例3: test_client_shutdown_async
# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import send [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)
示例4: test_send_not_enabled
# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import send [as 别名]
def test_send_not_enabled(self, time, send_remote):
time.return_value = 1328055286.51
with mock.patch.dict('os.environ', {'OPBEAT_DISABLE_SEND': 'true'}):
client = Client(
servers=['http://example.com'],
organization_id='organization_id',
app_id='app_id',
secret_token='secret',
)
client.send(**{
'foo': 'bar',
})
assert not send_remote.called
示例5: test_send_with_auth_header
# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import send [as 别名]
def test_send_with_auth_header(self, time, send_remote):
time.return_value = 1328055286.51
client = Client(
servers=["http://example.com"], organization_id="organization_id", app_id="app_id", secret_token="secret"
)
client.send(auth_header="foo", **{"foo": "bar"})
send_remote.assert_called_once_with(
url="http://example.com",
data=six.b("x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T"),
headers={
"Content-Type": "application/octet-stream",
"Authorization": "foo",
"User-Agent": "opbeat-python/%s" % opbeat.VERSION,
"X-Opbeat-Platform": self.client.get_platform_info(),
},
)
示例6: test_send_with_auth_header
# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import send [as 别名]
def test_send_with_auth_header(self, time, send_remote):
time.return_value = 1328055286.51
client = Client(
servers=['http://example.com'],
organization_id='organization_id',
app_id='app_id',
secret_token='secret',
)
client.send(auth_header='foo', **{
'foo': 'bar',
})
send_remote.assert_called_once_with(
url='http://example.com',
data=six.b('x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T'),
headers={
'Content-Type': 'application/octet-stream',
'Authorization': 'foo',
'User-Agent': 'opbeat-python/%s' % opbeat.VERSION,
'X-Opbeat-Platform': self.client.get_platform_info(),
},
)
示例7: test_send
# 需要导入模块: from opbeat.base import Client [as 别名]
# 或者: from opbeat.base.Client import send [as 别名]
def test_send(self, time, send_remote):
time.return_value = 1328055286.51
public = "public"
access_token = "secret"
client = Client(
servers=['http://example.com'],
organization_id='organization_id',
app_id='app_id',
secret_token='secret',
)
client.send(**{
'foo': 'bar',
})
send_remote.assert_called_once_with(
url='http://example.com',
data=six.b('x\x9c\xabVJ\xcb\xcfW\xb2RPJJ,R\xaa\x05\x00 \x98\x04T'),
headers={
'Content-Type': 'application/octet-stream',
'Authorization': 'Bearer %s' % (access_token),
'User-Agent': 'opbeat-python/%s' % opbeat.VERSION
},
)