本文整理匯總了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)