def test_user_post_save_existing_user_calls_copy_picture_to_profile(self, mock_init): user = UserFactory() mock_init.reset_mock() with patch.object(user, "copy_picture_to_profile") as mock_copy: user.save() mock_copy.assert_called_once_with() mock_init.assert_called_once_with()
def test_get_first_name(self): user = UserFactory() profile = user.profile user.first_name = "foo" assert profile.get_first_name() == "foo" profile.user = None profile.name = "bar foo" assert profile.get_first_name() == "bar" profile.name = "" assert profile.get_first_name() == ""
def _get_request_view_and_content(self, rf, create_content=True): request = rf.get("/") request.user = UserFactory() profile = request.user.profile profile.visibility = Visibility.PUBLIC profile.save() contents = [] if create_content: contents.extend([ ContentFactory(author=profile, order=3, pinned=True), ContentFactory(author=profile, order=2, pinned=True), ContentFactory(author=profile, order=1, pinned=True), ]) Content.objects.filter(id=contents[0].id).update(order=3) Content.objects.filter(id=contents[1].id).update(order=2) Content.objects.filter(id=contents[2].id).update(order=1) view = OrganizeContentProfileDetailView(request=request) view.object = profile view.target_profile = profile view.kwargs = {"guid": profile.guid} return request, view, contents, profile
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.user2 = AnonymousUser() cls.local_user = UserFactory() cls.public_content = ContentFactory( visibility=Visibility.PUBLIC, text="**Foobar**", author=cls.profile, ) cls.site_content = ContentFactory(visibility=Visibility.SITE, text="_Foobar_") cls.limited_content = ContentFactory(visibility=Visibility.LIMITED) cls.self_content = ContentFactory(visibility=Visibility.SELF) cls.remote_content = ContentFactory( visibility=Visibility.PUBLIC, remote_created=make_aware(datetime.datetime(2015, 1, 1)), author=cls.remote_profile, ) cls.ids = [ cls.public_content.id, cls.site_content.id, cls.limited_content.id, cls.self_content.id ] cls.set = { cls.public_content, cls.site_content, cls.limited_content, cls.self_content } cls.content_with_twitter_oembed = ContentFactory( text='class="twitter-tweet"') cls.content_with_mentions = ContentFactory( text="foo @{bar; %s} bar @{foo; %s}" % (cls.user.profile.handle, cls.remote_profile.handle), author=cls.local_user.profile, ) cls.content_with_url = ContentFactory( text="<p>https://example.com/foobar yay</p>", author=cls.local_user.profile, )
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.user2 = AnonymousUser() cls.local_user = UserFactory() cls.public_content = ContentFactory( visibility=Visibility.PUBLIC, text="**Foobar**", author=cls.profile, ) cls.site_content = ContentFactory( visibility=Visibility.SITE, text="_Foobar_" ) cls.limited_content = ContentFactory(visibility=Visibility.LIMITED) cls.self_content = ContentFactory(visibility=Visibility.SELF) cls.remote_content = ContentFactory( visibility=Visibility.PUBLIC, remote_created=make_aware(datetime.datetime(2015, 1, 1)), author=cls.remote_profile, ) cls.ids = [ cls.public_content.id, cls.site_content.id, cls.limited_content.id, cls.self_content.id ] cls.set = { cls.public_content, cls.site_content, cls.limited_content, cls.self_content }
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.anonymous_user = AnonymousUser() cls.other_user = PublicUserFactory() cls.create_content_set() cls.public_share = PublicContentFactory(share_of=cls.public_content, author=cls.other_user.profile) cls.public_share2 = PublicContentFactory(share_of=cls.public_content) cls.limited_share = LimitedContentFactory( share_of=cls.limited_content, author=cls.other_user.profile) cls.self_share = SelfContentFactory(share_of=cls.self_content, author=cls.other_user.profile) cls.site_share = SiteContentFactory(share_of=cls.site_content, author=cls.other_user.profile) cls.other_user.profile.following.add(cls.public_content.author, cls.profile) cls.limited_content_user = UserFactory() cls.limited_content_profile = cls.limited_content_user.profile cls.limited_share.limited_visibilities.add(cls.limited_content_profile) cls.limited_content.limited_visibilities.add( cls.limited_content_profile) cls.limited_content_profile.following.add(cls.other_user.profile)
def setUpTestData(cls): super().setUpTestData() user = UserFactory() cls.content = ContentFactory(author=user.profile)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory(username="******") cls.profile = cls.user.profile cls.profile.rsa_public_key = "fooobar" cls.profile.save()
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.profile = cls.user.profile cls.remote_profile = ProfileFactory() cls.remote_profile2 = ProfileFactory()
def test_local_reply_is_skipped(self, mock_update): user = UserFactory() ContentFactory(guid=self.comment.guid, author=user.profile) process_entity_comment(self.comment, ProfileFactory()) self.assertFalse(mock_update.called)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.create_content_set()
def test_local_profile_gets_sent(self, mock_send): user = UserFactory() mock_send.assert_called_once_with(send_profile, user.profile.id)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.profile = ProfileFactory() cls.user.profile.following.add(cls.profile)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() ContentFactory( pinned=True, author=cls.user.profile) # To ensure profile view can render
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.admin_user = AdminUserFactory()
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() ContentFactory(pinned=True, author=cls.user.profile)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() Profile.objects.filter(user__username=cls.user.username).update( visibility=Visibility.PUBLIC)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.profile = ProfileFactory()
def setUp(self): super().setUp() self.user = UserFactory() self.user2 = UserFactory() self.profile2 = self.user2.profile self.profile = ProfileFactory()
def test_local_profile_gets_sent(self, mock_send): user = UserFactory() user.profile.delete() self.assertTrue(mock_send.called is True)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.content1 = ContentFactory() cls.content2 = ContentFactory()
def test_local_content_gets_sent(self, mock_update, mock_send): user = UserFactory() mock_send.reset_mock() content = ContentFactory(author=user.profile) self.assertTrue(content.local) mock_send.assert_called_once_with(send_content, content.id)
def test_private_key(self, settings): settings.SOCIALHOME_GENERATE_USER_RSA_KEYS_ON_SAVE = True user = UserFactory() assert user.profile.private_key
def set_profile_with_user(self, create, extracted, **kwargs): user = UserFactory() self.author = user.profile self.save()
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.profile = cls.user.profile cls.remote_profile = ProfileFactory( rsa_public_key=get_dummy_private_key().publickey().exportKey(), )
def test_local_content_with_federate_false_does_not_get_sent( self, mock_update, mock_send): user = UserFactory() mock_send.reset_mock() ContentFactory(author=user.profile, federate=False) self.assertTrue(mock_send.called is False)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.profile = cls.user.profile cls.remote_profile = ProfileFactory(with_key=True) cls.create_content_set(author=cls.profile)
def setUp(self): super().setUp() self.content = ContentFactory() self.user = UserFactory() self.profile = self.user.profile
def test_hcard_responds_on_200_on_known_user(self, client): user = UserFactory(username="******") Profile.objects.filter(user__username="******").update(rsa_public_key="fooobar") response = client.get(reverse("federate:hcard", kwargs={"guid": user.profile.guid})) assert response.status_code == 200
def test_exception_calls_logger(self, mock_logger, mock_send): user = UserFactory() content = ContentFactory(author=user.profile) content.delete() self.assertTrue(mock_logger.called)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory()
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory(with_verified_email=True) cls.user2 = UserFactory(with_verified_email=True) cls.user3 = UserFactory() cls.verified_users = (cls.user.id, cls.user2.id)