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)
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'}], )
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, )
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)
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)
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)
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, ["*****@*****.**"])
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)
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)
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)
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()
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/"])
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")
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, ["*****@*****.**"] )