本文整理汇总了Python中mixpanel.Mixpanel.send_events_batch方法的典型用法代码示例。如果您正苦于以下问题:Python Mixpanel.send_events_batch方法的具体用法?Python Mixpanel.send_events_batch怎么用?Python Mixpanel.send_events_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mixpanel.Mixpanel
的用法示例。
在下文中一共展示了Mixpanel.send_events_batch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_events_batch
# 需要导入模块: from mixpanel import Mixpanel [as 别名]
# 或者: from mixpanel.Mixpanel import send_events_batch [as 别名]
def test_events_batch(self):
events_list = [
{
"event": "Signed Up",
"properties": {
"distinct_id": "13793",
"token": "e3bc4100330c35722740fb8c6f5abddc",
"Referred By": "Friend",
"time": 1371002000
}
},
{
"event": "Uploaded Photo",
"properties": {
"distinct_id": "13793",
"token": "e3bc4100330c35722740fb8c6f5abddc",
"Topic": "Vacation",
"time": 1371002104
}
}
]
token = "e3bc4100330c35722740fb8c6f5abddc"
mp = Mixpanel(token)
mock_response = Mock()
mock_response.read.return_value = '1'
data = mp._prepare_data(events_list)
with patch('urllib2.Request', return_value = mock_response) as mock_Request:
with patch('urllib2.urlopen', return_value = mock_response) as mock_urlopen:
mp.send_events_batch(events_list)
mock_Request.assert_called_once_with(self.track_request_url, data)