コード例 #1
0
ファイル: test_signals.py プロジェクト: jaywink/socialhome
 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()
コード例 #2
0
ファイル: test_models.py プロジェクト: jaywink/socialhome
 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() == ""
コード例 #3
0
    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
コード例 #4
0
 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,
     )
コード例 #5
0
 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
     }
コード例 #6
0
 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)
コード例 #7
0
 def setUpTestData(cls):
     super().setUpTestData()
     user = UserFactory()
     cls.content = ContentFactory(author=user.profile)
コード例 #8
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory(username="******")
     cls.profile = cls.user.profile
     cls.profile.rsa_public_key = "fooobar"
     cls.profile.save()
コード例 #9
0
ファイル: test_tasks.py プロジェクト: vchslv13/socialhome
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.profile = cls.user.profile
     cls.remote_profile = ProfileFactory()
     cls.remote_profile2 = ProfileFactory()
コード例 #10
0
 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)
コード例 #11
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.create_content_set()
コード例 #12
0
ファイル: test_signals.py プロジェクト: takumab/socialhome
 def test_local_profile_gets_sent(self, mock_send):
     user = UserFactory()
     mock_send.assert_called_once_with(send_profile, user.profile.id)
コード例 #13
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.profile = ProfileFactory()
     cls.user.profile.following.add(cls.profile)
コード例 #14
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     ContentFactory(
         pinned=True,
         author=cls.user.profile)  # To ensure profile view can render
コード例 #15
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.admin_user = AdminUserFactory()
コード例 #16
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     ContentFactory(pinned=True, author=cls.user.profile)
コード例 #17
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     Profile.objects.filter(user__username=cls.user.username).update(
         visibility=Visibility.PUBLIC)
コード例 #18
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.profile = ProfileFactory()
コード例 #19
0
ファイル: test_signals.py プロジェクト: takumab/socialhome
 def setUp(self):
     super().setUp()
     self.user = UserFactory()
     self.user2 = UserFactory()
     self.profile2 = self.user2.profile
     self.profile = ProfileFactory()
コード例 #20
0
 def test_local_profile_gets_sent(self, mock_send):
     user = UserFactory()
     user.profile.delete()
     self.assertTrue(mock_send.called is True)
コード例 #21
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.content1 = ContentFactory()
     cls.content2 = ContentFactory()
コード例 #22
0
ファイル: test_signals.py プロジェクト: takumab/socialhome
 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)
コード例 #23
0
 def test_private_key(self, settings):
     settings.SOCIALHOME_GENERATE_USER_RSA_KEYS_ON_SAVE = True
     user = UserFactory()
     assert user.profile.private_key
コード例 #24
0
 def set_profile_with_user(self, create, extracted, **kwargs):
     user = UserFactory()
     self.author = user.profile
     self.save()
コード例 #25
0
ファイル: test_tasks.py プロジェクト: vchslv13/socialhome
 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(), )
コード例 #26
0
 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)
コード例 #27
0
ファイル: test_tasks.py プロジェクト: vchslv13/socialhome
 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)
コード例 #28
0
 def setUp(self):
     super().setUp()
     self.content = ContentFactory()
     self.user = UserFactory()
     self.profile = self.user.profile
コード例 #29
0
ファイル: test_views.py プロジェクト: dissolve/socialhome
 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
コード例 #30
0
 def test_exception_calls_logger(self, mock_logger, mock_send):
     user = UserFactory()
     content = ContentFactory(author=user.profile)
     content.delete()
     self.assertTrue(mock_logger.called)
コード例 #31
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
コード例 #32
0
 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)