Exemplo n.º 1
0
    def test_entity_converter_call_to_xml(self):
        entity = Post()

        with patch.object(EntityConverter, "post_to_xml", return_value="foo") as mock_to_xml:
            entity_converter = EntityConverter(entity=entity)
            result = entity_converter.convert_to_xml()
            assert result == "foo"
            assert mock_to_xml.called
Exemplo n.º 2
0
 def build_send(self, from_user, to_user, entity, *args, **kwargs):
     """Build POST data for sending out to remotes."""
     converter = EntityConverter(entity)
     xml = converter.convert_to_xml()
     self.init_message(xml, from_user.handle, from_user.private_key)
     xml = quote_plus(
         self.create_salmon_envelope(to_user.key))
     data = urlencode({
         'xml': xml
     })
     return data
Exemplo n.º 3
0
 def test_entity_converter_converts_a_post(self):
     entity = Post(raw_content="raw_content", guid="guid", handle="handle", public=True, created_at=datetime.today())
     entity_converter = EntityConverter(entity)
     result = entity_converter.convert_to_xml()
     assert result.tag == "status_message"
     assert len(result.find("created_at").text) > 0
     result.find("created_at").text = ""  # timestamp makes testing painful
     post_converted = b"<status_message><raw_message>raw_content</raw_message><guid>guid</guid>" \
                      b"<diaspora_handle>handle</diaspora_handle><public>true</public><created_at>" \
                      b"</created_at></status_message>"
     assert etree.tostring(result) == post_converted