def test__user_details(self):
     self.login(self.profile1.username)
     profile_view = UserProfileView(self.profile1, self.request)
     details = profile_view._user_details([self.profile1.username, self.profile2.username])
     self.assertEqual(len(details), 2)
     self.assertEqual(details[0]["title"], self.profile1.fullname)
     self.assertEqual(details[1]["title"], self.profile2.fullname)
 def test_recent_contacts_most_recent_first(self):
     self.profile1.recent_contacts = ['some_user']
     self.login(self.profile1.username)
     profile_view = UserProfileView(self.profile2, self.request)
     profile_view._update_recent_contacts()
     recent = self.profile1.recent_contacts or []
     self.assertEqual(recent[0], self.profile2.username)
 def test_recent_contacts_length_limited(self):
     self.profile1.recent_contacts = [
         'user{0}'.format(n) for n in range(20)
     ]
     self.login(self.profile1.username)
     profile_view = UserProfileView(self.profile2, self.request)
     profile_view._update_recent_contacts()
     recent = self.profile1.recent_contacts or []
     self.assertLessEqual(len(recent), 20)
    def test_is_me(self):
        profile_view = UserProfileView(self.profile1, self.request)

        self.login(self.profile1.username)
        self.assertTrue(profile_view.is_me())
        self.logout()

        self.login(self.profile2.username)
        self.assertFalse(profile_view.is_me())
        self.logout()
    def test_is_me(self):
        profile_view = UserProfileView(self.profile1, self.request)

        self.login(self.profile1.username)
        self.assertTrue(profile_view.is_me())
        self.logout()

        self.login(self.profile2.username)
        self.assertFalse(profile_view.is_me())
        self.logout()
 def test__user_details(self):
     self.login(self.profile1.username)
     profile_view = UserProfileView(self.profile1, self.request)
     details = profile_view._user_details([
         self.profile1.username,
         self.profile2.username,
     ])
     self.assertEqual(len(details), 2)
     self.assertEqual(
         details[0]['title'],
         self.profile1.fullname,
     )
     self.assertEqual(
         details[1]['title'],
         self.profile2.fullname,
     )
    def test_recent_contacts_not_duplicated(self):
        self.login(self.profile1.username)
        profile_view = UserProfileView(self.profile2, self.request)
        profile_view._update_recent_contacts()
        self.assertIn(self.profile2.username, self.profile1.recent_contacts
                      or [])

        profile_view._update_recent_contacts()
        recent = self.profile1.recent_contacts or []
        self.assertEqual(recent.count(self.profile2.username), 1,
                         "Recent contact entry duplicated")
 def test_recent_contacts_self_excluded(self):
     self.login(self.profile1.username)
     profile_view = UserProfileView(self.profile1, self.request)
     profile_view._update_recent_contacts()
     self.assertNotIn(self.profile1.username, self.profile1.recent_contacts
                      or [])