Exemplo n.º 1
0
 def test_deletes_content(self):
     process_entity_retraction(
         Mock(entity_type="Post",
              target_guid=self.content.guid,
              handle=self.content.author.handle), self.content.author)
     with self.assertRaises(Content.DoesNotExist):
         Content.objects.get(id=self.content.id)
Exemplo n.º 2
0
 def test_deletes_content__share(self):
     process_entity_retraction(
         Mock(entity_type="Share",
              target_id=self.share.fid,
              actor_id=self.share.author.fid), self.share.author)
     with self.assertRaises(Content.DoesNotExist):
         Content.objects.get(id=self.share.id)
Exemplo n.º 3
0
 def test_deletes_content(self):
     process_entity_retraction(
         Mock(entity_type="Post", target_id=self.content.fid, actor_id=self.content.author.fid),
         self.content.author
     )
     with self.assertRaises(Content.DoesNotExist):
         Content.objects.get(id=self.content.id)
Exemplo n.º 4
0
 def test_does_nothing_if_content_is_not_local(self, mock_logger):
     process_entity_retraction(
         Mock(entity_type="Post", target_id=self.local_content.fid), Mock())
     mock_logger.assert_called_with(
         "Retracted remote content %s cannot be found",
         self.local_content.fid,
     )
Exemplo n.º 5
0
 def test_does_nothing_if_content_doesnt_exist(self, mock_logger):
     process_entity_retraction(
         Mock(entity_type="Post", target_id="https://example.com/notfound"),
         Mock())
     mock_logger.assert_called_with(
         "Retracted remote content %s cannot be found",
         "https://example.com/notfound")
Exemplo n.º 6
0
 def test_does_nothing_if_content_is_not_local(self, mock_logger):
     content = LocalContentFactory()
     process_entity_retraction(
         Mock(entity_type="Post", target_guid=content.guid), Mock())
     mock_logger.assert_called_with(
         "Local content %s cannot be retracted by a remote retraction!",
         content)
Exemplo n.º 7
0
 def test_removes_follower(self):
     self.remote_profile.following.add(self.profile)
     process_entity_retraction(
         base.Retraction(entity_type="Profile", _receiving_guid=self.profile.guid),
         self.remote_profile,
     )
     self.assertEqual(self.remote_profile.following.count(), 0)
Exemplo n.º 8
0
 def test_does_nothing_if_content_author_is_not_same_as_remote_profile(
         self, mock_logger):
     remote_profile = Mock()
     process_entity_retraction(
         Mock(entity_type="Post", target_guid=self.content.guid),
         remote_profile)
     mock_logger.assert_called_with(
         "Content %s is not owned by remote retraction profile %s",
         self.content, remote_profile)
Exemplo n.º 9
0
 def test_non_post_entity_types_are_skipped(self, mock_logger):
     process_entity_retraction(Mock(entity_type="foo"), Mock())
     mock_logger.assert_called_with("Ignoring retraction of entity_type %s",
                                    "foo")
Exemplo n.º 10
0
 def test_does_nothing_if_content_author_is_not_same_as_remote_profile(self, mock_logger):
     remote_profile = Mock()
     process_entity_retraction(Mock(entity_type="Post", target_id=self.content.fid), remote_profile)
     mock_logger.assert_called_with(
         "Content %s is not owned by remote retraction profile %s", self.content, remote_profile
     )
Exemplo n.º 11
0
 def test_does_nothing_if_content_is_not_local(self, mock_logger):
     process_entity_retraction(Mock(entity_type="Post", target_id=self.local_content.fid), Mock())
     mock_logger.assert_called_with(
         "Retracted remote content %s cannot be found", self.local_content.fid,
     )
Exemplo n.º 12
0
 def test_does_nothing_if_content_doesnt_exist(self, mock_logger):
     process_entity_retraction(Mock(entity_type="Post", target_id="https://example.com/notfound"), Mock())
     mock_logger.assert_called_with("Retracted remote content %s cannot be found", "https://example.com/notfound")
Exemplo n.º 13
0
 def test_non_post_entity_types_are_skipped(self, mock_logger):
     process_entity_retraction(Mock(entity_type="foo"), Mock())
     mock_logger.assert_called_with("Ignoring retraction of entity_type %s", "foo")
Exemplo n.º 14
0
 def test_does_nothing_if_content_doesnt_exist(self, mock_logger):
     process_entity_retraction(Mock(entity_type="Post", target_guid="bar"),
                               Mock())
     mock_logger.assert_called_with("Retracted content %s cannot be found",
                                    "bar")