コード例 #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)
コード例 #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'}],
     )
コード例 #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,
     )
コード例 #4
0
ファイル: signals.py プロジェクト: dut3062796s/socialhome
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)
コード例 #5
0
ファイル: test_tasks.py プロジェクト: jaywink/socialhome
 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)
コード例 #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)
コード例 #7
0
ファイル: test_tasks.py プロジェクト: vchslv13/socialhome
 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)
コード例 #8
0
ファイル: test_tasks.py プロジェクト: vchslv13/socialhome
 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,
         ["*****@*****.**"])
コード例 #9
0
ファイル: test_tasks.py プロジェクト: vchslv13/socialhome
 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)
コード例 #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)
コード例 #11
0
ファイル: test_tasks.py プロジェクト: vchslv13/socialhome
 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)
コード例 #12
0
ファイル: test_tasks.py プロジェクト: takumab/socialhome
 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()
コード例 #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/"])
コード例 #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")
コード例 #15
0
ファイル: test_tasks.py プロジェクト: jaywink/socialhome
 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)
コード例 #16
0
ファイル: test_tasks.py プロジェクト: jaywink/socialhome
 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)
コード例 #17
0
ファイル: test_tasks.py プロジェクト: jaywink/socialhome
 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)
コード例 #18
0
ファイル: test_tasks.py プロジェクト: jaywink/socialhome
 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, ["*****@*****.**"]
     )