Ejemplo n.º 1
0
    def it_presents_a_complete_user_record_correctly(self):
        user = User.from_api(get_user())
        eq_('id-from-customers-app', user.user_id)
        eq_('*****@*****.**', user.email)
        eq_('Joe Schmoe', user.name)
        eq_('the-app-id', user.app_id)
        eq_(123, user.session_count)
        eq_(1401970114, time.mktime(user.created_at.timetuple()))
        eq_(1393613864, time.mktime(user.remote_created_at.timetuple()))
        eq_(1401970114, time.mktime(user.updated_at.timetuple()))

        Avatar = create_class_instance('Avatar')  # noqa
        Company = create_class_instance('Company')  # noqa
        SocialProfile = create_class_instance('SocialProfile')  # noqa
        LocationData = create_class_instance('LocationData')  # noqa
        self.assertIsInstance(user.avatar, 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], 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, time.mktime(
            user.companies[0].remote_created_at.timetuple()))
        eq_(1401970114, time.mktime(
            user.companies[0].created_at.timetuple()))
        eq_(1401970114, time.mktime(
            user.companies[0].updated_at.timetuple()))
        eq_(1401970113, time.mktime(
            user.companies[0].last_request_at.timetuple()))
        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, 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, 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
Ejemplo n.º 2
0
    def it_presents_a_complete_user_record_correctly(self):
        user = User.from_api(get_user())
        eq_('id-from-customers-app', user.user_id)
        eq_('*****@*****.**', user.email)
        eq_('Joe Schmoe', user.name)
        eq_('the-app-id', user.app_id)
        eq_(123, user.session_count)
        eq_(1401970114, time.mktime(user.created_at.timetuple()))
        eq_(1393613864, time.mktime(user.remote_created_at.timetuple()))
        eq_(1401970114, time.mktime(user.updated_at.timetuple()))

        Avatar = create_class_instance('Avatar')  # noqa
        Company = create_class_instance('Company')  # noqa
        SocialProfile = create_class_instance('SocialProfile')  # noqa
        LocationData = create_class_instance('LocationData')  # noqa
        self.assertIsInstance(user.avatar, 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], 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,
            time.mktime(user.companies[0].remote_created_at.timetuple()))
        eq_(1401970114, time.mktime(user.companies[0].created_at.timetuple()))
        eq_(1401970114, time.mktime(user.companies[0].updated_at.timetuple()))
        eq_(1401970113,
            time.mktime(user.companies[0].last_request_at.timetuple()))
        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, 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, 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
Ejemplo n.º 3
0
 def it_returns_inner_user_object_for_conversation(self):
     User = create_class_instance('User')  # noqa
     payload = Notification(**test_conversation_notification)
     self.assertIsInstance(payload.model.user, User.__class__)
Ejemplo n.º 4
0
 def it_returns_correct_model_type_for_conversation(self):
     Conversation = create_class_instance('Conversation')  # noqa
     payload = Notification(**test_conversation_notification)
     eq_(payload.model_type, Conversation.__class__)
Ejemplo n.º 5
0
 def it_returns_instance_of_conversation(self):
     Conversation = create_class_instance('Conversation')  # noqa
     payload = Notification(**test_conversation_notification)
     self.assertIsInstance(payload.model, Conversation.__class__)
Ejemplo n.º 6
0
 def it_returns_instance_of_user(self):
     User = create_class_instance('User')  # noqa
     payload = Notification(**test_user_notification)
     self.assertIsInstance(payload.model, User.__class__)
Ejemplo n.º 7
0
    def it_returns_correct_model_type_for_user(self):
        payload = Notification(**test_user_notification)
        User = create_class_instance('User')  # noqa

        self.assertIsInstance(payload.model, User.__class__)
        eq_(payload.model_type, User.__class__)
Ejemplo n.º 8
0
 def it_returns_inner_user_object_for_conversation(self):
     User = create_class_instance('User')  # noqa
     payload = Notification(**test_conversation_notification)
     self.assertIsInstance(payload.model.user, User.__class__)
Ejemplo n.º 9
0
 def it_returns_correct_model_type_for_conversation(self):
     Conversation = create_class_instance('Conversation')  # noqa
     payload = Notification(**test_conversation_notification)
     eq_(payload.model_type, Conversation.__class__)
Ejemplo n.º 10
0
 def it_returns_instance_of_conversation(self):
     Conversation = create_class_instance('Conversation')  # noqa
     payload = Notification(**test_conversation_notification)
     self.assertIsInstance(payload.model, Conversation.__class__)
Ejemplo n.º 11
0
 def it_returns_instance_of_user(self):
     User = create_class_instance('User')  # noqa
     payload = Notification(**test_user_notification)
     self.assertIsInstance(payload.model, User.__class__)
Ejemplo n.º 12
0
    def it_returns_correct_model_type_for_user(self):
        payload = Notification(**test_user_notification)
        User = create_class_instance('User')  # noqa

        self.assertIsInstance(payload.model, User.__class__)
        eq_(payload.model_type, User.__class__)