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_reply = PublicContentFactory(parent=cls.public_content) cls.limited_reply = LimitedContentFactory(parent=cls.limited_content) cls.self_reply = SelfContentFactory(parent=cls.self_content) cls.site_reply = SiteContentFactory(parent=cls.site_content) cls.public_share = PublicContentFactory(share_of=cls.public_content, author=cls.remote_profile) cls.limited_share = LimitedContentFactory(share_of=cls.limited_content, author=cls.remote_profile) cls.self_share = SelfContentFactory(share_of=cls.self_content, author=cls.remote_profile) cls.site_share = SiteContentFactory(share_of=cls.site_content, author=cls.remote_profile) cls.public_share_reply = PublicContentFactory(parent=cls.public_share) cls.share_limited_reply = LimitedContentFactory( parent=cls.limited_share) cls.share_self_reply = SelfContentFactory(parent=cls.self_share) cls.share_site_reply = SiteContentFactory(parent=cls.site_share) cls.limited_content_user = UserFactory() cls.limited_content_profile = cls.limited_content_user.profile cls.limited_reply.limited_visibilities.add(cls.limited_content_profile) cls.limited_content.limited_visibilities.add( cls.limited_content_profile)
def setUpTestData(cls): super().setUpTestData() cls.public_content = ContentFactory(pinned=True) cls.public_tag_content = ContentFactory(text="#foobar") cls.limited_content = LimitedContentFactory() cls.tag = Tag.objects.get(name="foobar") cls.site_content = SiteContentFactory(pinned=True) cls.site_tag_content = SiteContentFactory(text="#foobar") cls.self_user = UserFactory() cls.self_content = SelfContentFactory(author=cls.self_user.profile, pinned=True) cls.self_tag_content = SelfContentFactory(author=cls.self_user.profile, text="#foobar") cls.other_user = UserFactory() cls.anonymous_user = AnonymousUser() cls.other_user.profile.following.add(cls.public_content.author, cls.self_user.profile) cls.public_reply = PublicContentFactory(parent=cls.public_content) cls.limited_reply = LimitedContentFactory(parent=cls.limited_content) cls.self_reply = SelfContentFactory(parent=cls.self_content) cls.site_reply = SiteContentFactory(parent=cls.site_content) cls.public_share = PublicContentFactory(share_of=cls.public_content, author=cls.self_user.profile) cls.limited_share = LimitedContentFactory(share_of=cls.limited_content, author=cls.self_user.profile) cls.self_share = SelfContentFactory(share_of=cls.self_content, author=cls.self_user.profile) cls.site_share = SiteContentFactory(share_of=cls.site_content, author=cls.self_user.profile) cls.public_share_reply = PublicContentFactory(parent=cls.public_share) cls.share_limited_reply = LimitedContentFactory( parent=cls.limited_share) cls.share_self_reply = SelfContentFactory(parent=cls.self_share) cls.share_site_reply = SiteContentFactory(parent=cls.site_share)
def setUpTestData(cls): super().setUpTestData() cls.public_content = PublicContentFactory( pinned=True, author=ProfileFactory(visibility=Visibility.SELF)) cls.public_tag_content = PublicContentFactory(text="#foobar") cls.limited_content = LimitedContentFactory(author=ProfileFactory( visibility=Visibility.SELF)) cls.tag = Tag.objects.get(name="foobar") cls.site_content = SiteContentFactory( pinned=True, author=ProfileFactory(visibility=Visibility.SELF)) cls.site_tag_content = SiteContentFactory(text="#foobar") cls.self_user = UserFactory() cls.self_content = SelfContentFactory(author=cls.self_user.profile, pinned=True) cls.self_tag_content = SelfContentFactory(author=cls.self_user.profile, text="#foobar") cls.other_user = UserFactory() cls.anonymous_user = AnonymousUser() cls.other_user.profile.following.add(cls.public_content.author, cls.self_user.profile) cls.other_user.profile.followed_tags.add(cls.tag) cls.limited_content_user = UserFactory() cls.limited_content_profile = cls.limited_content_user.profile cls.limited_content.limited_visibilities.add( cls.limited_content_profile) cls.limited_tag_content = LimitedContentFactory(text="#foobar") cls.limited_tag_content.limited_visibilities.add( cls.limited_content_profile) cls.local_user = UserFactory() cls.local_content = PublicContentFactory(author=cls.local_user.profile)
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.content = PublicContentFactory(author=cls.remote_profile) cls.content2 = PublicContentFactory(author=cls.remote_profile) cls.limited_content = LimitedContentFactory(author=cls.remote_profile) cls.limited_content2 = LimitedContentFactory(author=cls.profile) cls.user_content = PublicContentFactory(author=cls.profile) cls.share = PublicContentFactory(share_of=cls.content) cls.reply = PublicContentFactory(parent=cls.content)
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() PublicContentFactory(text="#foobar") SiteContentFactory(text="#foobar") SelfContentFactory(text="#foobar") LimitedContentFactory(text="#foobar") cls.content = PublicContentFactory(text="#spam") cls.content2 = SiteContentFactory(text="#spam") SelfContentFactory(text="#spam") LimitedContentFactory(text="#spam") cls.profile.followed_tags.add(Tag.objects.get(name="spam"))
def setUpTestData(cls): super().setUpTestData() author = UserFactory() author.profile.rsa_private_key = get_dummy_private_key().exportKey() author.profile.save() cls.public_content = PublicContentFactory(author=author.profile) cls.remote_reply = PublicContentFactory(parent=cls.public_content, author=ProfileFactory()) cls.reply = PublicContentFactory(parent=cls.public_content) cls.share = PublicContentFactory(share_of=cls.public_content) cls.share_reply = PublicContentFactory(parent=cls.share) cls.limited_content = LimitedContentFactory(author=author.profile) cls.limited_reply = LimitedContentFactory(parent=cls.limited_content) cls.remote_limited_reply = LimitedContentFactory(parent=cls.limited_content) cls.limited_content.limited_visibilities.set((cls.limited_reply.author, cls.remote_limited_reply.author))
def setUpTestData(cls): super().setUpTestData() author = UserFactory() cls.create_content_set(author=author.profile) cls.user = UserWithKeyFactory() cls.profile = cls.user.profile cls.limited_content2 = LimitedContentFactory(author=cls.profile)
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.content = PublicContentFactory() cls.profile.following.add(cls.content.author) cls.limited_content = LimitedContentFactory() cls.reply = PublicContentFactory(parent=cls.content)
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.user_recipient = PublicProfileFactory() cls.user_recipient2 = PublicProfileFactory() cls.content = PublicContentFactory(author=cls.remote_profile) cls.content2 = PublicContentFactory(author=cls.remote_profile) cls.limited_content = LimitedContentFactory(author=cls.remote_profile) cls.limited_content2 = LimitedContentFactory(author=cls.profile) cls.limited_content_with_recipients = LimitedContentWithRecipientsFactory(recipients=[ cls.user_recipient, cls.user_recipient2 ]) cls.user_content = PublicContentFactory(author=cls.profile) cls.share = PublicContentFactory(share_of=cls.content) cls.reply = PublicContentFactory(parent=cls.content) cls.reply_parent_with_recipients = PublicContentFactory(parent=cls.limited_content_with_recipients)
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.content = PublicContentFactory(author=cls.remote_profile) SiteContentFactory(author=cls.profile) SelfContentFactory(author=cls.profile) LimitedContentFactory(author=cls.profile)
def setUpTestData(cls): super().setUpTestData() cls.content = PublicContentFactory() cls.content2 = PublicContentFactory() SiteContentFactory() SelfContentFactory() LimitedContentFactory()
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.content = PublicContentFactory(text="#foobar") SiteContentFactory(text="#foobar") SelfContentFactory(text="#foobar") LimitedContentFactory(text="#foobar")
def setUpTestData(cls): super().setUpTestData() cls.profile = ProfileFactory() cls.limited_content = LimitedContentFactory(author=cls.profile) cls.profile2 = ProfileFactory(with_key=True) cls.profile3 = ProfileFactory(with_key=True) cls.limited_content.limited_visibilities.set((cls.profile2, cls.profile3))
def create_content_set(target, author=None): if not author: author = PublicProfileFactory() target.public_content = PublicContentFactory(author=author) target.site_content = SiteContentFactory(author=author) target.self_content = SelfContentFactory(author=author) target.limited_content = LimitedContentFactory(author=author)
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.other_user = UserFactory() cls.content = ContentFactory(author=cls.user.profile) cls.limited_content = LimitedContentFactory(author=cls.user.profile) cls.limited_content.limited_visibilities.add(cls.other_user.profile)
def setUpTestData(cls): super().setUpTestData() author = UserFactory() private_key = get_dummy_private_key().exportKey().decode("utf-8") Profile.objects.filter(id=author.profile.id).update(rsa_private_key=private_key) author.profile.refresh_from_db() cls.public_content = ContentFactory(author=author.profile, visibility=Visibility.PUBLIC) cls.remote_content = ContentFactory(visibility=Visibility.PUBLIC) cls.remote_profile = ProfileFactory(with_key=True) cls.remote_reply = ContentFactory(parent=cls.public_content, author=cls.remote_profile) cls.reply = ContentFactory(parent=cls.public_content, author=author.profile) cls.reply2 = ContentFactory(parent=cls.remote_content, author=author.profile) cls.limited_content = LimitedContentFactory(author=cls.remote_profile) cls.limited_local_content = LimitedContentFactory(author=author.profile) cls.limited_reply = LimitedContentFactory(author=author.profile, parent=cls.limited_content) cls.limited_local_reply = LimitedContentFactory(author=author.profile, parent=cls.limited_local_content) cls.limited_local_reply.limited_visibilities.add(cls.remote_profile)
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.remote_profile.followers.add(cls.profile) cls.create_content_set(author=cls.remote_profile) cls.other_public_content = PublicContentFactory() SiteContentFactory() SelfContentFactory() LimitedContentFactory()
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.local_user = UserFactory() cls.create_content_set() cls.public_tagged = PublicContentFactory(text="#foobar", author=cls.profile) cls.site_tagged = SiteContentFactory(text="#foobar", author=cls.profile) cls.self_tagged = SelfContentFactory(text="#foobar", author=cls.profile) cls.limited_tagged = LimitedContentFactory(text="#foobar", author=cls.profile) cls.tag = cls.public_tagged.tags.first()
def setUpTestData(cls): super().setUpTestData() cls.user = UserFactory() cls.profile = ProfileFactory(visibility=Visibility.PUBLIC, handle='*****@*****.**') cls.profile2 = ProfileFactory(visibility=Visibility.SITE, handle='*****@*****.**') cls.self_profile = ProfileFactory(visibility=Visibility.SELF, handle="*****@*****.**") cls.content = PublicContentFactory() cls.limited_content = LimitedContentFactory(author=cls.user.profile) cls.limited_content.limited_visibilities.set((cls.profile, cls.profile2)) cls.user.profile.following.add(cls.profile2)
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.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)
def test_save__collects_recipients__include_following(self): user = UserWithContactFactory() content = LimitedContentFactory(author=user.profile) serializer = ContentSerializer( instance=content, partial=True, context={"request": Mock(user=user)}, data={ "recipients": [self.user_recipient.handle, self.user_recipient2.handle], "visibility": Visibility.LIMITED.value, "include_following": True, }) serializer.is_valid(True) content = serializer.save() actual = set(content.limited_visibilities.all().order_by("id")) expected = set( list(user.profile.following.all().order_by("id")) + [self.user_recipient, self.user_recipient2] ) self.assertSetEqual(actual, expected)
def setUpTestData(cls): super().setUpTestData() cls.create_local_and_remote_user() cls.create_content_set() LimitedContentFactory() cls.limited_content.limited_visibilities.add(cls.profile)