Ejemplo n.º 1
0
 def test_only_public_content_calls_make_federable_entity(self, mock_maker):
     send_content_retraction(self.limited_content.id,
                             self.limited_content.author_id)
     mock_maker.assert_not_called()
     send_content_retraction(self.public_content.id,
                             self.public_content.author_id)
     mock_maker.assert_called_once_with(self.public_content,
                                        self.public_content.author)
Ejemplo n.º 2
0
 def test_handle_create_payload_is_called(self, mock_maker, mock_enqueue):
     send_content_retraction(self.public_content, self.public_content.author_id)
     mock_enqueue.assert_called_once_with(
         ANY,
         "entity",
         self.public_content.author.federable,
         [{'endpoint': 'https://relay.iliketoast.net/receive/public', 'fid': '', 'public': True,
           'protocol': 'diaspora'}],
     )
Ejemplo n.º 3
0
 def test_handle_create_payload_is_called(self, mock_maker, mock_enqueue):
     send_content_retraction(self.public_content, self.public_content.author_id)
     mock_enqueue.assert_called_once_with(
         ANY,
         "entity",
         self.public_content.author.federable,
         [],
         payload_logger=None,
         job_timeout=10000,
     )
Ejemplo n.º 4
0
def federate_content_retraction(instance, **kwargs):
    """Send out local content retractions to the federation layer."""
    if instance.local:
        logger.debug(
            'federate_content_retraction: Sending out Content retraction: %s',
            instance)
        try:
            # Process immediately since things wont be in the db otherwise
            send_content_retraction(instance, instance.author_id)
        except Exception as ex:
            logger.exception("Failed to federate_content_retraction %s: %s",
                             instance, ex)
Ejemplo n.º 5
0
 def test_only_limited_and_public_content_calls_make_federable_retraction(self, mock_maker):
     send_content_retraction(self.self_content, self.self_content.author_id)
     self.assertTrue(mock_maker.called is False)
     send_content_retraction(self.site_content, self.site_content.author_id)
     self.assertTrue(mock_maker.called is False)
     send_content_retraction(self.limited_content, self.limited_content.author_id)
     mock_maker.assert_called_once_with(self.limited_content, self.limited_content.author)
     mock_maker.reset_mock()
     send_content_retraction(self.public_content, self.public_content.author_id)
     mock_maker.assert_called_once_with(self.public_content, self.public_content.author)
Ejemplo n.º 6
0
 def test_only_limited_and_public_content_calls_make_federable_retraction(self, mock_maker):
     send_content_retraction(self.self_content, self.self_content.author_id)
     self.assertTrue(mock_maker.called is False)
     send_content_retraction(self.site_content, self.site_content.author_id)
     self.assertTrue(mock_maker.called is False)
     send_content_retraction(self.limited_content, self.limited_content.author_id)
     mock_maker.assert_called_once_with(self.limited_content, self.limited_content.author)
     mock_maker.reset_mock()
     send_content_retraction(self.public_content, self.public_content.author_id)
     mock_maker.assert_called_once_with(self.public_content, self.public_content.author)
Ejemplo n.º 7
0
 def test_content_not_sent_in_debug_mode(self, mock_send):
     send_content_retraction(self.public_content,
                             self.public_content.author_id)
     self.assertTrue(mock_send.called is False)
Ejemplo n.º 8
0
 def test_handle_create_payload_is_called(self, mock_maker, mock_sender):
     send_content_retraction(self.public_content,
                             self.public_content.author_id)
     mock_sender.assert_called_once_with(
         "entity", self.public_content.author.federable,
         ["*****@*****.**"])
Ejemplo n.º 9
0
 def test_warning_is_logged_on_no_entity(self, mock_logger, mock_maker):
     send_content_retraction(self.public_content,
                             self.public_content.author_id)
     self.assertTrue(mock_logger.called is True)
Ejemplo n.º 10
0
 def test_handle_create_payload_is_called(self, mock_maker, mock_sender,
                                          mock_handler):
     send_content_retraction(self.public_content.id,
                             self.public_content.author_id)
     mock_handler.assert_called_once_with("entity",
                                          self.public_content.author)
Ejemplo n.º 11
0
 def test_limited_retraction_calls_get_recipients(self, mock_maker,
                                                  mock_get, mock_send):
     send_content_retraction(self.limited_content2,
                             self.limited_content2.author.id)
     self.assertTrue(mock_send.called is True)
     self.assertTrue(mock_get.called is True)
Ejemplo n.º 12
0
 def test_content_not_sent_in_debug_mode(self, mock_send):
     send_content_retraction(self.public_content,
                             self.public_content.author_id)
     mock_send.assert_not_called()
Ejemplo n.º 13
0
 def test_handle_create_payload_is_called(self, mock_maker, mock_sender):
     send_content_retraction(self.public_content,
                             self.public_content.author_id)
     mock_sender.assert_called_once_with(
         "entity", self.public_content.author,
         ["diaspora://[email protected]/profile/"])
Ejemplo n.º 14
0
 def test_send_document_is_called(self, mock_sender, mock_payloader):
     send_content_retraction(self.public_content.id,
                             self.public_content.author_id)
     url = "https://%s/receive/public" % settings.SOCIALHOME_RELAY_DOMAIN
     mock_sender.assert_called_once_with(url, "payload")
Ejemplo n.º 15
0
 def test_limited_retraction_calls_get_recipients(self, mock_maker, mock_get, mock_send):
     send_content_retraction(self.limited_content2, self.limited_content2.author.id)
     self.assertTrue(mock_send.called is True)
     self.assertTrue(mock_get.called is True)
Ejemplo n.º 16
0
 def test_content_not_sent_in_debug_mode(self, mock_send):
     send_content_retraction(self.public_content, self.public_content.author_id)
     self.assertTrue(mock_send.called is False)
Ejemplo n.º 17
0
 def test_warning_is_logged_on_no_entity(self, mock_logger, mock_maker):
     send_content_retraction(self.public_content, self.public_content.author_id)
     self.assertTrue(mock_logger.called is True)
Ejemplo n.º 18
0
 def test_handle_create_payload_is_called(self, mock_maker, mock_sender):
     send_content_retraction(self.public_content, self.public_content.author_id)
     mock_sender.assert_called_once_with(
         "entity", self.public_content.author.federable, ["*****@*****.**"]
     )