Exemplo n.º 1
0
 def test_get_base_attributes_returns_only_intended_attributes(self):
     entity = Post()
     attrs = get_base_attributes(entity).keys()
     assert set(attrs) == {
         'created_at', 'guid', 'handle', 'location', 'photos',
         'provider_display_name', 'public', 'raw_content'
     }
Exemplo n.º 2
0
 def test_returns_xml_document(self):
     entity = Post()
     document = get_full_xml_representation(entity, "")
     document = re.sub(r"<created_at>.*</created_at>", "", document)  # Dates are annoying to compare
     assert document == "<XML><post><status_message><text></text><guid></guid>" \
                        "<author></author><public>false</public>" \
                        "<provider_display_name></provider_display_name></status_message></post></XML>"
Exemplo n.º 3
0
 def test_get_base_attributes_returns_only_intended_attributes(self):
     entity = Post()
     attrs = get_base_attributes(entity).keys()
     assert set(attrs) == {
         "created_at",
         "guid",
         "handle",
         "location",
         "provider_display_name",
         "public",
         "raw_content",
         "signature",
     }
     entity = Profile()
     attrs = get_base_attributes(entity).keys()
     assert set(attrs) == {
         "created_at",
         "guid",
         "handle",
         "name",
         "email",
         "gender",
         "raw_content",
         "location",
         "public",
         "nsfw",
         "public_key",
         "image_urls",
         "tag_list",
         "signature",
     }
Exemplo n.º 4
0
 def test_send_reply__to_remote_follower(self, mock_make, mock_forward, mock_sender):
     post = Post()
     mock_make.return_value = post
     send_reply(self.limited_local_reply.id, self.limited_local_reply.activities.first().fid)
     mock_sender.assert_called_once_with(post, self.limited_local_reply.author.federable, [
         self.remote_profile.get_recipient_for_visibility(self.limited_local_reply.visibility),
     ])
     self.assertTrue(mock_forward.called is False)
Exemplo n.º 5
0
 def test_send_reply__to_remote_author(self, mock_make, mock_forward, mock_sender):
     post = Post()
     mock_make.return_value = post
     send_reply(self.reply2.id, self.reply2.activities.first().fid)
     mock_sender.assert_called_once_with(post, self.reply2.author.federable, [
         self.remote_content.author.get_recipient_for_visibility(self.reply2.visibility),
     ], payload_logger=None)
     self.assertTrue(mock_forward.called is False)
Exemplo n.º 6
0
 def test_handle_send_is_called(self, mock_maker, mock_send):
     post = Post()
     mock_maker.return_value = post
     send_share(self.share.id, self.share.activities.first().fid)
     mock_send.assert_called_once_with(
         post,
         self.share.author.federable,
         [self.content.author.get_recipient_for_visibility(self.share.visibility)],
     )
Exemplo n.º 7
0
 def test_send_reply__limited_content(self, mock_make, mock_forward, mock_sender):
     post = Post()
     mock_make.return_value = post
     send_reply(self.limited_reply.id, self.limited_reply.activities.first().fid)
     mock_sender.assert_called_once_with(
         post,
         self.limited_reply.author.federable,
         [self.remote_profile.get_recipient_for_visibility(Visibility.LIMITED)],
     )
Exemplo n.º 8
0
 def test_handle_send_is_called(self, mock_maker, mock_send):
     post = Post()
     mock_maker.return_value = post
     send_content(self.public_content.id, self.public_content.activities.first().fid)
     mock_send.assert_called_once_with(
         post,
         self.public_content.author.federable,
         [{'endpoint': 'https://relay.iliketoast.net/receive/public', 'fid': '', 'public': True,
           'protocol': 'diaspora'}],
     )
Exemplo n.º 9
0
def post():
    return Post(
        raw_content="""One more test before sleep 😅 This time with an image.

![](https://jasonrobinson.me/media/uploads/2020/12/27/1b2326c6-554c-4448-9da3-bdacddf2bb77.jpeg)""",
        public=True,
        provider_display_name="Socialhome",
        id="guid",
        guid="guid",
        actor_id="*****@*****.**",
        handle="*****@*****.**",
    )
Exemplo n.º 10
0
 def test_handle_send_is_called__limited_content(self, mock_maker, mock_send):
     post = Post()
     mock_maker.return_value = post
     send_content(
         self.limited_content.id,
         self.limited_content.activities.first().fid,
         recipient_id=self.remote_profile.id,
     )
     mock_send.assert_called_once_with(
         post,
         self.limited_content.author.federable,
         [self.remote_profile.get_recipient_for_visibility(Visibility.LIMITED)],
     )
Exemplo n.º 11
0
 def test_handle_send_is_called(self, mock_maker, mock_send):
     post = Post()
     mock_maker.return_value = post
     send_content(self.public_content.id, self.public_content.activities.first().fid)
     mock_send.assert_called_once_with(
         post,
         self.public_content.author.federable,
         [
             {'endpoint': 'https://matrix.127.0.0.1:8000', 'fid': self.public_content.author.mxid, 'public': True,
              'protocol': 'matrix'},
         ],
         payload_logger=None,
     )
Exemplo n.º 12
0
 def test_post_is_converted_to_diasporapost(self, private_key):
     entity = Post()
     assert isinstance(get_outbound_entity(entity, private_key),
                       DiasporaPost)
Exemplo n.º 13
0
 def test_doesnt_send_to_local_share_author(self, mock_maker, mock_send):
     post = Post()
     mock_maker.return_value = post
     send_share(self.local_share.id, self.local_share.activities.first().fid)
     mock_send.assert_called_once_with(post, self.local_share.author.federable, [])
Exemplo n.º 14
0
 def test_send_reply__ignores_local_root_author(self, mock_make, mock_forward, mock_sender):
     post = Post()
     mock_make.return_value = post
     send_reply(self.reply.id, self.reply.activities.first().fid)
     self.assertTrue(mock_sender.called is False)
     self.assertTrue(mock_forward.called is False)