当前位置: 首页>>代码示例>>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;未经允许,请勿转载。