Add mappings for Post.provider_display_name

merge-requests/130/head
Jason Robinson 2016-09-05 22:21:32 +03:00
rodzic 0172690137
commit f979b8e91e
5 zmienionych plików z 12 dodań i 3 usunięć

Wyświetl plik

@ -4,6 +4,9 @@
- `federation.outbound.handle_create_payload` parameter `to_user` is now optional. Public posts don't need a recipient. This also affects Diaspora protocol `build_send` method where the change is reflected similarly. [#43](https://github.com/jaywink/social-federation/pull/43)
- In practise this means the signature has changed for `handle_create_payload` and `build_send` from **`from_user, to_user, entity`** to **`entity, from_user, to_user=None`**.
## Added
- `Post.provider_display_name` is now supported in the entity outbound/inbound mappers. [#44](https://github.com/jaywink/social-federation/pull/44)
## [0.4.1] - 2016-09-04
## Fixes

Wyświetl plik

@ -37,7 +37,8 @@ class DiasporaPost(DiasporaEntityMixin, Post):
{'guid': self.guid},
{'diaspora_handle': self.handle},
{'public': 'true' if self.public else 'false'},
{'created_at': format_dt(self.created_at)}
{'created_at': format_dt(self.created_at)},
{'provider_display_name': self.provider_display_name},
])
return element

Wyświetl plik

@ -7,14 +7,17 @@ from federation.entities.diaspora.entities import DiasporaComment, DiasporaPost,
class TestEntitiesConvertToXML(object):
def test_post_to_xml(self):
entity = DiasporaPost(raw_content="raw_content", guid="guid", handle="handle", public=True)
entity = DiasporaPost(
raw_content="raw_content", guid="guid", handle="handle", public=True,
provider_display_name="Socialhome"
)
result = entity.to_xml()
assert result.tag == "status_message"
assert len(result.find("created_at").text) > 0
result.find("created_at").text = "" # timestamp makes testing painful
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>"
b"</created_at><provider_display_name>Socialhome</provider_display_name></status_message>"
assert etree.tostring(result) == converted
def test_comment_to_xml(self):

Wyświetl plik

@ -23,6 +23,7 @@ class TestDiasporaEntityMappersReceive(object):
assert post.handle == "alice@alice.diaspora.example.org"
assert post.public == False
assert post.created_at == datetime(2011, 7, 20, 1, 36, 7)
assert post.provider_display_name == "Socialhome"
def test_message_to_objects_comment(self):
entities = message_to_objects(DIASPORA_POST_COMMENT)

Wyświetl plik

@ -36,6 +36,7 @@ DIASPORA_POST_SIMPLE = """<XML>
<diaspora_handle>alice@alice.diaspora.example.org</diaspora_handle>
<public>false</public>
<created_at>2011-07-20 01:36:07 UTC</created_at>
<provider_display_name>Socialhome</provider_display_name>
</status_message>
</post>
</XML>