当前位置: 首页>>代码示例>>Python>>正文


Python User.increment方法代码示例

本文整理汇总了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)
开发者ID:jkeyes,项目名称:python-intercom,代码行数:19,代码来源:test_user.py

示例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)
开发者ID:jkeyes,项目名称:python-intercom,代码行数:70,代码来源:test_user.py


注:本文中的intercom.user.User.increment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。