本文整理汇总了Python中raven.base.Client.send方法的典型用法代码示例。如果您正苦于以下问题:Python Client.send方法的具体用法?Python Client.send怎么用?Python Client.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raven.base.Client
的用法示例。
在下文中一共展示了Client.send方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_transport
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.base.Client import send [as 别名]
def test_custom_transport(self):
c = Client(dsn="mock://some_username:[email protected]:8143/1")
data = dict(a=42, b=55, c=list(range(50)))
c.send(**data)
expected_message = c.encode(data)
self.assertIn('mock://localhost:8143/api/1/store/', Client._registry._transports)
mock_cls = Client._registry._transports['mock://localhost:8143/api/1/store/']
assert mock_cls._data == expected_message
示例2: test_send_with_auth_header
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.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"], public_key="public", secret_key="secret", project=1)
client.send(auth_header="foo", **{"foo": "bar"})
send_remote.assert_called_once_with(
url="http://example.com",
data="eJyrVkrLz1eyUlBKSixSqgUAIJgEVA==",
headers={
"User-Agent": "raven-python/%s" % (raven.VERSION,),
"Content-Type": "application/octet-stream",
"X-Sentry-Auth": "foo",
},
)
示例3: test_custom_transport
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.base.Client import send [as 别名]
def test_custom_transport(self):
try:
Client.register_scheme('mock', DummyScheme)
except:
pass
c = Client(dsn="mock://some_username:[email protected]:8143/1")
data = dict(a=42, b=55, c=range(50))
c.send(**data)
expected_message = c.encode(data)
mock_cls = Client._registry._transports['mock']
assert mock_cls._data == expected_message
示例4: test_send_with_auth_header
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.base.Client import send [as 别名]
def test_send_with_auth_header(self, time, send_remote):
time.return_value = 1328055286.51
client = Client(dsn="http://public:[email protected]/1")
client.send(auth_header="foo", **{"foo": "bar"})
send_remote.assert_called_once_with(
url="http://example.com/api/1/store/",
data=client.encode({"foo": "bar"}),
headers={
"User-Agent": "raven-python/%s" % (raven.VERSION,),
"Content-Type": "application/octet-stream",
"Content-Encoding": client.get_content_encoding(),
"X-Sentry-Auth": "foo",
},
)
示例5: test_send_with_auth_header
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.base.Client import send [as 别名]
def test_send_with_auth_header(self, time, send_remote):
time.return_value = 1328055286.51
client = Client(
dsn='http://public:[email protected]/1',
)
client.send(auth_header='foo', **{
'foo': 'bar',
})
send_remote.assert_called_once_with(
url='http://example.com/api/1/store/',
data=six.b('eJyrVkrLz1eyUlBKSixSqgUAIJgEVA=='),
headers={
'User-Agent': 'raven-python/%s' % (raven.VERSION,),
'Content-Type': 'application/octet-stream',
'X-Sentry-Auth': 'foo'
},
)
示例6: test_custom_transport
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.base.Client import send [as 别名]
def test_custom_transport(self):
c = Client(dsn="mock://some_username:[email protected]:8143/1")
data = dict(a=42, b=55, c=list(range(50)))
c.send(**data)
mock_cls = c._transport_cache['mock://some_username:[email protected]:8143/1'].get_transport()
expected_message = zlib.decompress(c.encode(data))
actual_message = zlib.decompress(mock_cls._data)
# These loads()/dumps() pairs order the dict keys before comparing the string.
# See GH504
self.assertEqual(
json.dumps(json.loads(expected_message.decode('utf-8')), sort_keys=True),
json.dumps(json.loads(actual_message.decode('utf-8')), sort_keys=True)
)
示例7: test_custom_transport
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.base.Client import send [as 别名]
def test_custom_transport(self):
c = Client(dsn="mock://some_username:[email protected]:8143/1")
data = dict(a=42, b=55, c=list(range(50)))
c.send(**data)
expected_message = zlib.decompress(base64.b64decode(c.encode(data)))
self.assertIn('mock://localhost:8143/api/1/store/', Client._registry._transports)
mock_cls = Client._registry._transports['mock://localhost:8143/api/1/store/']
actual_message = zlib.decompress(base64.b64decode(mock_cls._data))
# These loads()/dumps() pairs order the dict keys before comparing the string.
# See GH504
self.assertEqual(
json.dumps(json.loads(expected_message.decode('utf-8')), sort_keys=True),
json.dumps(json.loads(actual_message.decode('utf-8')), sort_keys=True)
)
示例8: test_send_with_auth_header
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.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'],
public_key='public',
secret_key='secret',
project=1,
)
client.send(auth_header='foo', **{
'foo': 'bar',
})
send_remote.assert_called_once_with(
url='http://example.com',
data='eJyrVkrLz1eyUlBKSixSqgUAIJgEVA==',
headers={
'Content-Type': 'application/octet-stream',
'X-Sentry-Auth': 'foo'
},
)
示例9: test_send
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.base.Client import send [as 别名]
def test_send(self, time, send_remote):
time.return_value = 1328055286.51
client = Client(
servers=['http://example.com'],
public_key='public',
secret_key='secret',
project=1,
)
client.send(**{
'foo': 'bar',
})
send_remote.assert_called_once_with(
url='http://example.com',
data='eJyrVkrLz1eyUlBKSixSqgUAIJgEVA==',
headers={
'Content-Type': 'application/octet-stream',
'X-Sentry-Auth': 'Sentry sentry_timestamp=1328055286.51, '
'sentry_client=raven-python/%s, sentry_version=2.0, sentry_key=public' % (raven.VERSION,)
},
)
示例10: send
# 需要导入模块: from raven.base import Client [as 别名]
# 或者: from raven.base.Client import send [as 别名]
def send(self, **kwargs):
"""
Serializes and signs ``data`` and passes the payload off to ``send_remote``
raven.contrib.django.client.DjangoClient does a check for
self.servers, just bypass that and delegate to the primary
raven.base.Client base class which will juse encode and fwd
the data on to send_encoded.
"""
return Client.send(self, **kwargs)