def test_from_remote_profile(self): remote_profile = BaseProfileFactory(public=False) profile = Profile.from_remote_profile(remote_profile) self.assertEqual(profile.guid, remote_profile.guid) self.assertEqual(profile.handle, remote_profile.handle) self.assertEqual(profile.name, remote_profile.name) self.assertEqual(profile.visibility, Visibility.LIMITED) self.assertEqual(profile.image_url_large, remote_profile.image_urls["large"]) self.assertEqual(profile.image_url_medium, remote_profile.image_urls["medium"]) self.assertEqual(profile.image_url_small, remote_profile.image_urls["small"]) self.assertEqual(profile.location, remote_profile.location) self.assertEqual(profile.email, remote_profile.email) self.assertEqual(profile.rsa_public_key, remote_profile.public_key) # Update to public remote_profile_update = BaseProfileFactory(public=True, guid=remote_profile.guid, handle=remote_profile.handle) profile = Profile.from_remote_profile(remote_profile_update) self.assertEqual(profile.guid, remote_profile.guid) self.assertEqual(profile.handle, remote_profile.handle) self.assertEqual(profile.visibility, Visibility.PUBLIC) # Make sure public key doesn't get deleted if it doesn't have a value public_key = profile.rsa_public_key assert public_key remote_profile_update = BaseProfileFactory(public_key="", guid=remote_profile.guid, handle=remote_profile.handle) profile = Profile.from_remote_profile(remote_profile_update) self.assertEqual(profile.rsa_public_key, public_key) remote_profile_update = BaseProfileFactory(public_key=None, guid=remote_profile.guid, handle=remote_profile.handle) profile = Profile.from_remote_profile(remote_profile_update) self.assertEqual(profile.rsa_public_key, public_key)
def test_from_remote_profile_absolute_image_url(self): remote_profile = BaseProfileFactory(public=False) remote_profile.image_urls["small"] = "https://example1.com/sm" remote_profile.image_urls["medium"] = "https://example2.com/me" remote_profile.image_urls["large"] = "https://example3.com/lg" profile = Profile.from_remote_profile(remote_profile) self.assertEqual(profile.image_url_small, "https://example1.com/sm") self.assertEqual(profile.image_url_medium, "https://example2.com/me") self.assertEqual(profile.image_url_large, "https://example3.com/lg")
def test_from_remote_profile_relative_image_url(self): remote_profile = BaseProfileFactory(public=False) remote_profile.handle = "*****@*****.**" remote_profile.image_urls["small"] = "/sm" remote_profile.image_urls["medium"] = "/me" remote_profile.image_urls["large"] = "/lg" profile = Profile.from_remote_profile(remote_profile) self.assertEqual(profile.image_url_small, "https://example.com/sm") self.assertEqual(profile.image_url_medium, "https://example.com/me") self.assertEqual(profile.image_url_large, "https://example.com/lg")
def test_search_by_handle_lowercases_before_fetching(self, mock_retrieve): mock_retrieve.return_value = BaseProfileFactory() self.get( "%s?q=%s" % (reverse("search:global"), "*****@*****.**"), follow=True) mock_retrieve.assert_called_once_with( "*****@*****.**")
def setUpTestData(cls): super().setUpTestData() cls.post = entities.PostFactory() cls.comment = base.Comment() cls.retraction = base.Retraction() cls.relationship = base.Relationship() cls.follow = base.Follow() cls.profile = BaseProfileFactory() cls.share = BaseShareFactory()
def setUpTestData(cls): super().setUpTestData() cls.post = entities.PostFactory() cls.comment = base.Comment() cls.retraction = base.Retraction() cls.follow = base.Follow() cls.profile = BaseProfileFactory() cls.share = BaseShareFactory() cls.receiving_user = UserFactory() cls.receiving_profile = cls.receiving_user.profile
def test_from_remote_profile_relative_image_url(self): remote_profile = BaseProfileFactory(public=False) remote_profile.handle = "foo@localhost" remote_profile.image_urls["small"] = "/sm" remote_profile.image_urls["medium"] = "/me" remote_profile.image_urls["large"] = "/lg" profile = Profile.from_remote_profile(remote_profile) self.assertEqual(profile.image_url_small, "https://localhost/sm") self.assertEqual(profile.image_url_medium, "https://localhost/me") self.assertEqual(profile.image_url_large, "https://localhost/lg")