Esempio n. 1
0
 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(Intercom, 'post', return_value=body) as mock_method:  # noqa
         user.increment('mad')
         eq_(user.to_dict['custom_attributes']['mad'], 1)
         user.save()
         ok_('email' not in user.identity_hash)
         ok_('user_id' in user.identity_hash)
Esempio n. 2
0
class DescribeIncrementingCustomAttributeFields(unittest.TestCase):
    def setUp(self):  # noqa
        created_at = datetime.utcnow()
        params = {
            'email': '*****@*****.**',
            'user_id': 'i-1224242',
            'custom_attributes': {
                'mad': 123,
                'another': 432,
                'other': time.mktime(created_at.timetuple()),
                'thing': 'yay'
            }
        }
        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_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)
Esempio n. 3
0
class DescribeIncrementingCustomAttributeFields(unittest.TestCase):

    def setUp(self):  # noqa
        created_at = datetime.utcnow()
        params = {
            'email': '*****@*****.**',
            'user_id': 'i-1224242',
            'custom_attributes': {
                'mad': 123,
                'another': 432,
                'other': time.mktime(created_at.timetuple()),
                'thing': 'yay'
            }
        }
        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_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)
Esempio n. 4
0
 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(Intercom, 'post',
                       return_value=body) as mock_method:  # noqa
         user.increment('mad')
         eq_(user.to_dict['custom_attributes']['mad'], 1)
         user.save()
         ok_('email' not in user.identity_hash)
         ok_('user_id' in user.identity_hash)
Esempio n. 5
0
class DescribeIncrementingCustomAttributeFields(unittest.TestCase):
    def setUp(self):  # noqa
        created_at = datetime.utcnow()
        params = {
            'email': '*****@*****.**',
            'user_id': 'i-1224242',
            'custom_attributes': {
                'mad': 123,
                'another': 432,
                'other': time.mktime(created_at.timetuple()),
                'thing': 'yay'
            }
        }
        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_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(Intercom, 'post',
                          return_value=body) as mock_method:  # noqa
            user.increment('mad')
            eq_(user.to_dict['custom_attributes']['mad'], 1)
            user.save()
            ok_('email' not in user.identity_hash)
            ok_('user_id' in user.identity_hash)
Esempio n. 6
0
class DescribeIncrementingCustomAttributeFields(unittest.TestCase):

    def setUp(self):  # noqa
        created_at = datetime.utcnow()
        params = {
            'email': '*****@*****.**',
            'user_id': 'i-1224242',
            'custom_attributes': {
                'mad': 123,
                'another': 432,
                'other': time.mktime(created_at.timetuple()),
                'thing': 'yay'
            }
        }
        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_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(Intercom, 'post', return_value=body) as mock_method:  # noqa
            user.increment('mad')
            eq_(user.to_dict['custom_attributes']['mad'], 1)
            user.save()
            ok_('email' not in user.identity_hash)
            ok_('user_id' in user.identity_hash)