kopia lustrzana https://gitlab.com/jaywink/federation
Add mappings for Post.provider_display_name
rodzic
0172690137
commit
f979b8e91e
|
@ -3,6 +3,9 @@
|
||||||
## Breaking changes
|
## Breaking changes
|
||||||
- `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)
|
- `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`**.
|
- 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
|
## [0.4.1] - 2016-09-04
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ class DiasporaPost(DiasporaEntityMixin, Post):
|
||||||
{'guid': self.guid},
|
{'guid': self.guid},
|
||||||
{'diaspora_handle': self.handle},
|
{'diaspora_handle': self.handle},
|
||||||
{'public': 'true' if self.public else 'false'},
|
{'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
|
return element
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,17 @@ from federation.entities.diaspora.entities import DiasporaComment, DiasporaPost,
|
||||||
|
|
||||||
class TestEntitiesConvertToXML(object):
|
class TestEntitiesConvertToXML(object):
|
||||||
def test_post_to_xml(self):
|
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()
|
result = entity.to_xml()
|
||||||
assert result.tag == "status_message"
|
assert result.tag == "status_message"
|
||||||
assert len(result.find("created_at").text) > 0
|
assert len(result.find("created_at").text) > 0
|
||||||
result.find("created_at").text = "" # timestamp makes testing painful
|
result.find("created_at").text = "" # timestamp makes testing painful
|
||||||
converted = b"<status_message><raw_message>raw_content</raw_message><guid>guid</guid>" \
|
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"<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
|
assert etree.tostring(result) == converted
|
||||||
|
|
||||||
def test_comment_to_xml(self):
|
def test_comment_to_xml(self):
|
||||||
|
|
|
@ -23,6 +23,7 @@ class TestDiasporaEntityMappersReceive(object):
|
||||||
assert post.handle == "alice@alice.diaspora.example.org"
|
assert post.handle == "alice@alice.diaspora.example.org"
|
||||||
assert post.public == False
|
assert post.public == False
|
||||||
assert post.created_at == datetime(2011, 7, 20, 1, 36, 7)
|
assert post.created_at == datetime(2011, 7, 20, 1, 36, 7)
|
||||||
|
assert post.provider_display_name == "Socialhome"
|
||||||
|
|
||||||
def test_message_to_objects_comment(self):
|
def test_message_to_objects_comment(self):
|
||||||
entities = message_to_objects(DIASPORA_POST_COMMENT)
|
entities = message_to_objects(DIASPORA_POST_COMMENT)
|
||||||
|
|
|
@ -36,6 +36,7 @@ DIASPORA_POST_SIMPLE = """<XML>
|
||||||
<diaspora_handle>alice@alice.diaspora.example.org</diaspora_handle>
|
<diaspora_handle>alice@alice.diaspora.example.org</diaspora_handle>
|
||||||
<public>false</public>
|
<public>false</public>
|
||||||
<created_at>2011-07-20 01:36:07 UTC</created_at>
|
<created_at>2011-07-20 01:36:07 UTC</created_at>
|
||||||
|
<provider_display_name>Socialhome</provider_display_name>
|
||||||
</status_message>
|
</status_message>
|
||||||
</post>
|
</post>
|
||||||
</XML>
|
</XML>
|
||||||
|
|
Ładowanie…
Reference in New Issue