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


Python User.from_api方法代码示例

本文整理汇总了Python中intercom.user.User.from_api方法的典型用法代码示例。如果您正苦于以下问题:Python User.from_api方法的具体用法?Python User.from_api怎么用?Python User.from_api使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在intercom.user.User的用法示例。


在下文中一共展示了User.from_api方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: it_presents_a_complete_user_record_correctly

# 需要导入模块: from intercom.user import User [as 别名]
# 或者: from intercom.user.User import from_api [as 别名]
    def it_presents_a_complete_user_record_correctly(self):
        user = User.from_api(get_user())
        eq_('id-from-customers-app', user.user_id)
        eq_('[email protected]', user.email)
        eq_('Joe Schmoe', user.name)
        eq_('the-app-id', user.app_id)
        eq_(123, user.session_count)
        eq_(1401970114, calendar.timegm(user.created_at.utctimetuple()))
        eq_(1393613864, calendar.timegm(user.remote_created_at.utctimetuple()))
        eq_(1401970114, calendar.timegm(user.updated_at.utctimetuple()))

        Avatar = define_lightweight_class('avatar', 'Avatar')  # noqa
        Company = define_lightweight_class('company', 'Company')  # noqa
        SocialProfile = define_lightweight_class('social_profile', 'SocialProfile')  # noqa
        LocationData = define_lightweight_class('locaion_data', 'LocationData')  # noqa
        self.assertIsInstance(user.avatar.__class__, Avatar.__class__)
        img_url = 'https://graph.facebook.com/1/picture?width=24&height=24'
        eq_(img_url, user.avatar.image_url)

        self.assertIsInstance(user.companies, list)
        eq_(1, len(user.companies))
        self.assertIsInstance(user.companies[0].__class__, Company.__class__)
        eq_('123', user.companies[0].company_id)
        eq_('bbbbbbbbbbbbbbbbbbbbbbbb', user.companies[0].id)
        eq_('the-app-id', user.companies[0].app_id)
        eq_('Company 1', user.companies[0].name)
        eq_(1390936440, calendar.timegm(
            user.companies[0].remote_created_at.utctimetuple()))
        eq_(1401970114, calendar.timegm(
            user.companies[0].created_at.utctimetuple()))
        eq_(1401970114, calendar.timegm(
            user.companies[0].updated_at.utctimetuple()))
        eq_(1401970113, calendar.timegm(
            user.companies[0].last_request_at.utctimetuple()))
        eq_(0, user.companies[0].monthly_spend)
        eq_(0, user.companies[0].session_count)
        eq_(1, user.companies[0].user_count)
        eq_([], user.companies[0].tag_ids)

        self.assertIsInstance(user.custom_attributes, FlatStore)
        eq_('b', user.custom_attributes["a"])
        eq_(2, user.custom_attributes["b"])

        eq_(4, len(user.social_profiles))
        twitter_account = user.social_profiles[0]
        self.assertIsInstance(twitter_account.__class__, SocialProfile.__class__)
        eq_('twitter', twitter_account.name)
        eq_('abc', twitter_account.username)
        eq_('http://twitter.com/abc', twitter_account.url)

        self.assertIsInstance(user.location_data.__class__, LocationData.__class__)
        eq_('Dublin', user.location_data.city_name)
        eq_('EU', user.location_data.continent_code)
        eq_('Ireland', user.location_data.country_name)
        eq_('90', user.location_data.latitude)
        eq_('10', user.location_data.longitude)
        eq_('IRL', user.location_data.country_code)

        ok_(user.unsubscribed_from_emails)
        eq_("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11", user.user_agent_data)  # noqa
开发者ID:jkeyes,项目名称:python-intercom,代码行数:62,代码来源:test_user.py

示例2: it_presents_created_at_and_last_impression_at_as_datetime

# 需要导入模块: from intercom.user import User [as 别名]
# 或者: from intercom.user.User import from_api [as 别名]
 def it_presents_created_at_and_last_impression_at_as_datetime(self):
     now = datetime.utcnow()
     now_ts = calendar.timegm(now.utctimetuple())
     user = User.from_api(
         {'created_at': now_ts, 'last_impression_at': now_ts})
     self.assertIsInstance(user.created_at, datetime)
     eq_(now.strftime('%c'), user.created_at.strftime('%c'))
     self.assertIsInstance(user.last_impression_at, datetime)
     eq_(now.strftime('%c'), user.last_impression_at.strftime('%c'))
开发者ID:jkeyes,项目名称:python-intercom,代码行数:11,代码来源:test_user.py

示例3: it_can_convert

# 需要导入模块: from intercom.user import User [as 别名]
# 或者: from intercom.user.User import from_api [as 别名]
    def it_can_convert(self):  # noqa
        lead = Lead.from_api({'user_id': 'contact_id'})
        user = User.from_api({'id': 'user_id'})

        with patch.object(Client, 'post', returns=get_user()) as mock_method:  # noqa
            self.client.leads.convert(lead, user)
            mock_method.assert_called_once_with(
                '/contacts/convert',
                {
                    'contact': {'user_id': lead.user_id},
                    'user': {'id': user.id}
                })
开发者ID:iwoca,项目名称:python-intercom,代码行数:14,代码来源:test_lead.py

示例4: it_rejects_nested_data_structures_in_custom_attributes

# 需要导入模块: from intercom.user import User [as 别名]
# 或者: from intercom.user.User import from_api [as 别名]
    def it_rejects_nested_data_structures_in_custom_attributes(self):
        user = User()
        with assert_raises(ValueError):
            user.custom_attributes["thing"] = [1]

        with assert_raises(ValueError):
            user.custom_attributes["thing"] = {1: 2}

        with assert_raises(ValueError):
            user.custom_attributes = {1: {2: 3}}

        user = User.from_api(get_user())
        with assert_raises(ValueError):
            user.custom_attributes["thing"] = [1]
开发者ID:jkeyes,项目名称:python-intercom,代码行数:16,代码来源:test_user.py

示例5: it_will_allow_extra_attributes_in_response_from_api

# 需要导入模块: from intercom.user import User [as 别名]
# 或者: from intercom.user.User import from_api [as 别名]
 def it_will_allow_extra_attributes_in_response_from_api(self):
     user = User.from_api({'new_param': 'some value'})
     eq_('some value', user.new_param)
开发者ID:jkeyes,项目名称:python-intercom,代码行数:5,代码来源:test_user.py


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