本文整理汇总了Python中intercom.user.User.increment方法的典型用法代码示例。如果您正苦于以下问题:Python User.increment方法的具体用法?Python User.increment怎么用?Python User.increment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intercom.user.User
的用法示例。
在下文中一共展示了User.increment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: it_can_save_after_increment
# 需要导入模块: from intercom.user import User [as 别名]
# 或者: from intercom.user.User import increment [as 别名]
def it_can_save_after_increment(self): # noqa
user = User(
email=None, user_id="i-1224242",
companies=[{'company_id': 6, 'name': 'Intercom'}])
body = {
'custom_attributes': {},
'email': "",
'user_id': 'i-1224242',
'companies': [{
'company_id': 6,
'name': 'Intercom'
}]
}
with patch.object(Client, 'post', return_value=body) as mock_method: # noqa
user.increment('mad')
eq_(user.to_dict()['custom_attributes']['mad'], 1)
self.client.users.save(user)
示例2: DescribeIncrementingCustomAttributeFields
# 需要导入模块: from intercom.user import User [as 别名]
# 或者: from intercom.user.User import increment [as 别名]
class DescribeIncrementingCustomAttributeFields(unittest.TestCase):
def setUp(self): # noqa
self.client = Client()
created_at = datetime.utcnow()
params = {
'email': '[email protected]',
'user_id': 'i-1224242',
'custom_attributes': {
'mad': 123,
'another': 432,
'other': time.mktime(created_at.timetuple()),
'thing': 'yay',
'logins': None,
}
}
self.user = User(**params)
@istest
def it_increments_up_by_1_with_no_args(self):
self.user.increment('mad')
eq_(self.user.to_dict()['custom_attributes']['mad'], 124)
@istest
def it_increments_up_by_given_value(self):
self.user.increment('mad', 4)
eq_(self.user.to_dict()['custom_attributes']['mad'], 127)
@istest
def it_increments_down_by_given_value(self):
self.user.increment('mad', -1)
eq_(self.user.to_dict()['custom_attributes']['mad'], 122)
@istest
def it_can_increment_new_custom_data_fields(self):
self.user.increment('new_field', 3)
eq_(self.user.to_dict()['custom_attributes']['new_field'], 3)
@istest
def it_can_increment_none_values(self):
self.user.increment('logins')
eq_(self.user.to_dict()['custom_attributes']['logins'], 1)
@istest
def it_can_call_increment_on_the_same_key_twice_and_increment_by_2(self): # noqa
self.user.increment('mad')
self.user.increment('mad')
eq_(self.user.to_dict()['custom_attributes']['mad'], 125)
@istest
def it_can_save_after_increment(self): # noqa
user = User(
email=None, user_id="i-1224242",
companies=[{'company_id': 6, 'name': 'Intercom'}])
body = {
'custom_attributes': {},
'email': "",
'user_id': 'i-1224242',
'companies': [{
'company_id': 6,
'name': 'Intercom'
}]
}
with patch.object(Client, 'post', return_value=body) as mock_method: # noqa
user.increment('mad')
eq_(user.to_dict()['custom_attributes']['mad'], 1)
self.client.users.save(user)