當前位置: 首頁>>代碼示例>>Python>>正文


Python Mixpanel._prepare_data方法代碼示例

本文整理匯總了Python中mixpanel.Mixpanel._prepare_data方法的典型用法代碼示例。如果您正苦於以下問題:Python Mixpanel._prepare_data方法的具體用法?Python Mixpanel._prepare_data怎麽用?Python Mixpanel._prepare_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mixpanel.Mixpanel的用法示例。


在下文中一共展示了Mixpanel._prepare_data方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_events_batch

# 需要導入模塊: from mixpanel import Mixpanel [as 別名]
# 或者: from mixpanel.Mixpanel import _prepare_data [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)
開發者ID:daemonburrito,項目名稱:mixpanel-python,代碼行數:32,代碼來源:test.py

示例2: test_alias

# 需要導入模塊: from mixpanel import Mixpanel [as 別名]
# 或者: from mixpanel.Mixpanel import _prepare_data [as 別名]
 def test_alias(self):
     token = '12345'
     mp = Mixpanel(token)
     mock_response = Mock()
     mock_response.read.return_value = '1'
     with patch('urllib2.urlopen', return_value = mock_response) as mock_urlopen:
         mp.alias('amq','3680')
     data = mp._prepare_data({'event': '$create_alias', 'properties': {'distinct_id': '3680', 'alias': 'amq', 'token': '12345'}})
     mock_urlopen.assert_called_once_with(self.engage_request_url, data)
開發者ID:daemonburrito,項目名稱:mixpanel-python,代碼行數:11,代碼來源:test.py

示例3: test_track

# 需要導入模塊: from mixpanel import Mixpanel [as 別名]
# 或者: from mixpanel.Mixpanel import _prepare_data [as 別名]
 def test_track(self):
     token = '12345'
     mp = Mixpanel(token)
     mock_response = Mock()
     mock_response.read.return_value = '1'
     with patch('urllib2.urlopen', return_value = mock_response) as mock_urlopen:
         mp.track('button press', {'size': 'big', 'color': 'blue'})
     data = mp._prepare_data({'event': 'button press', 'properties': {'token': '12345', 'size': 'big', 'color': 'blue'}})
     mock_urlopen.assert_called_once_with(self.track_request_url, data)
開發者ID:daemonburrito,項目名稱:mixpanel-python,代碼行數:11,代碼來源:test.py

示例4: test_people_set

# 需要導入模塊: from mixpanel import Mixpanel [as 別名]
# 或者: from mixpanel.Mixpanel import _prepare_data [as 別名]
 def test_people_set(self):
     token = '12345'
     mp = Mixpanel(token)
     mock_response = Mock()
     mock_response.read.return_value = '1'
     with patch('urllib2.urlopen', return_value = mock_response) as mock_urlopen:
         mp.people_set('amq', {'birth month': 'october', 'favorite color': 'purple'})
     data = mp._prepare_data({'$token': '12345', '$distinct_id': 'amq', '$set': {'birth month': 'october', 'favorite color': 'purple'}})
     mock_urlopen.assert_called_once_with(self.engage_request_url, data)
開發者ID:daemonburrito,項目名稱:mixpanel-python,代碼行數:11,代碼來源:test.py

示例5: test_prepare_data

# 需要導入模塊: from mixpanel import Mixpanel [as 別名]
# 或者: from mixpanel.Mixpanel import _prepare_data [as 別名]
 def test_prepare_data(self):
     prepared_ab = Mixpanel._prepare_data({'a': 'b'})
     self.assertEqual('data=eyJhIjogImIifQ%3D%3D&verbose=1', prepared_ab)
開發者ID:daemonburrito,項目名稱:mixpanel-python,代碼行數:5,代碼來源:test.py


注:本文中的mixpanel.Mixpanel._prepare_data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。