Beispiel #1
0
 def test_generate_new_rsa_key(self):
     profile = ProfileFactory()
     current_rsa_key = profile.rsa_private_key
     current_public_key = profile.rsa_public_key
     profile.generate_new_rsa_key()
     profile.save()
     assert profile.rsa_private_key !=  current_rsa_key
     assert profile.rsa_public_key != current_public_key
Beispiel #2
0
 def test_get_absolute_url(self):
     profile = ProfileFactory(guid="1234")
     assert profile.get_absolute_url() == "/p/1234/"
 def test_create(self):
     content = Content.objects.create(text="foobar", author=ProfileFactory())
     assert content.guid
 def test_renders_with_nsfw_shield(self):
     content = Content.objects.create(
         text="<img src='localhost'> #nsfw", guid="barfoo", author=ProfileFactory()
     )
     self.assertEqual(content.rendered, '<p><img class="nsfw" src="localhost"/> '
                                        '<a href="/streams/tag/nsfw/">#nsfw</a></p>')
Beispiel #5
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.profile = ProfileFactory()
     cls.user.profile.following.add(cls.profile)
Beispiel #6
0
 def test_create(self):
     Content.objects.create(text="foobar",
                            guid="barfoo",
                            author=ProfileFactory())
Beispiel #7
0
 def test_does_not_forward_relayable_if_not_local_content(self, mock_rq):
     process_entity_comment(self.comment, ProfileFactory())
     Content.objects.get(fid=self.comment.id, parent=self.content)
     self.assertFalse(mock_rq.called)
Beispiel #8
0
 def test_reply_is_created_from_entity(self):
     process_entity_comment(self.comment, ProfileFactory())
     content = Content.objects.get(fid=self.comment.id, parent=self.content)
     self.assertEqual(content.limited_visibilities.count(), 0)
 def test_reply_is_updated_from_entity(self):
     ContentFactory(guid=self.comment.guid)
     process_entity_comment(self.comment, ProfileFactory())
     content = Content.objects.get(guid=self.comment.guid, parent=self.content)
     self.assertEqual(content.text, self.comment.raw_content)
Beispiel #10
0
 def test_reply_is_created_from_entity(self):
     process_entity_comment(self.comment, ProfileFactory())
     Content.objects.get(guid=self.comment.guid, parent=self.content)
Beispiel #11
0
 def test_receive_task_runs(self, mock_get_sender, mock_handle_receive,
                            mock_process_entities):
     profile = ProfileFactory()
     mock_get_sender.return_value = profile
     receive_task("foobar")
     mock_process_entities.assert_called_with(["entity"], profile=profile)
Beispiel #12
0
 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 setUpTestData(cls):
     super().setUpTestData()
     cls.profile = ProfileFactory(guid="1234")
     cls.user = UserFactory()
 def test_empty_guid(self):
     with self.assertRaises(ValueError):
         ProfileFactory(guid="")
Beispiel #15
0
 def test_remote_url(self):
     profile = ProfileFactory(guid="1234")
     assert profile.remote_url == "https://example.com/people/1234"
Beispiel #16
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.profile = cls.user.profile
     cls.remote_profile = ProfileFactory()
Beispiel #17
0
 def test_returns_existing_profile(self):
     profile = ProfileFactory(handle="*****@*****.**")
     assert get_sender_profile("*****@*****.**") == profile
Beispiel #18
0
 def test_reply_text_fields_are_cleaned(self):
     self.comment.raw_content = "<script>alert('yup');</script>"
     process_entity_comment(self.comment, ProfileFactory())
     content = Content.objects.get(fid=self.comment.id, parent=self.content)
     self.assertEqual(content.text,
                      "&lt;script&gt;alert('yup');&lt;/script&gt;")
Beispiel #19
0
 def test_local_profile_public_key_is_returned(self):
     profile = ProfileFactory()
     self.assertEqual(sender_key_fetcher(profile.handle), profile.rsa_public_key)
Beispiel #20
0
 def test_local_reply_is_skipped(self, mock_update):
     user = UserFactory()
     ContentFactory(fid=self.comment.id, author=user.profile)
     process_entity_comment(self.comment, ProfileFactory())
     self.assertFalse(mock_update.called)
Beispiel #21
0
 def test_post_is_created_from_entity(self):
     entity = entities.PostFactory()
     process_entity_post(entity, ProfileFactory())
     Content.objects.get(guid=entity.guid)
Beispiel #22
0
 def test_gets_guid_on_save_with_user(self):
     content = Content(text="foobar")
     content.save(author=ProfileFactory())
     assert content.guid
Beispiel #23
0
 def test_post_is_updated_from_entity(self):
     entity = entities.PostFactory()
     ContentFactory(guid=entity.guid)
     process_entity_post(entity, ProfileFactory())
     content = Content.objects.get(guid=entity.guid)
     assert content.text == entity.raw_content
 def test_renders(self):
     content = Content.objects.create(text="# Foobar <img src='localhost'>", guid="barfoo", author=ProfileFactory())
     self.assertEqual(content.rendered, '<h1>Foobar <img src="localhost"></h1>')
 def test_profile_image_urls_default_to_ponies(self):
     profile = ProfileFactory(image_url_small="", image_url_medium="", image_url_large="")
     ponies = get_pony_urls()
     urls = [profile.image_url_large, profile.image_url_medium, profile.image_url_small]
     self.assertEqual(urls, ponies)
 def test_renders_with_oembed(self):
     content = Content.objects.create(
         text="foobar", guid="barfoo", author=ProfileFactory(),
         oembed=OEmbedCacheFactory()
     )
     self.assertEqual(content.rendered, "<p>foobar</p><br>%s" % content.oembed.oembed)
 def test___str__(self):
     profile = ProfileFactory(name="foo")
     assert str(profile) == f"foo ({profile.fid})"
Beispiel #28
0
 def test_safer_image_url_small(self):
     profile = ProfileFactory.build(image_url_small="/foobar", handle="foo@localhost")
     assert profile.safer_image_url_small == "https://localhost/foobar"
     profile.image_url_small = "https://example.com/foobar"
     assert profile.safer_image_url_small == "https://example.com/foobar"
Beispiel #29
0
 def test_post_is_created_from_entity(self):
     entity = entities.PostFactory()
     process_entity_post(entity, ProfileFactory())
     content = Content.objects.get(fid=entity.id)
     self.assertEqual(content.limited_visibilities.count(), 0)
Beispiel #30
0
 def test_home_url(self):
     profile = ProfileFactory(guid="1234")
     assert profile.home_url == profile.remote_url
     user = UserFactory()
     assert user.profile.home_url == user.profile.get_absolute_url()
Beispiel #31
0
 def test_local_content_is_skipped(self, mock_update):
     entity = entities.PostFactory(id=self.local_content.fid)
     process_entity_post(entity, ProfileFactory())
     self.assertFalse(mock_update.called)
Beispiel #32
0
 def test_non_local_profile_does_not_get_sent(self, mock_send):
     profile = ProfileFactory()
     profile.delete()
     self.assertTrue(mock_send.called is False)
Beispiel #33
0
 def test_safer_image_url_small(self):
     profile = ProfileFactory.build(image_url_small="/foobar", handle="foo@localhost")
     assert profile.safer_image_url_small == "https://localhost/foobar"
     profile.image_url_small = "https://example.com/foobar"
     assert profile.safer_image_url_small == "https://example.com/foobar"