diff --git a/federation/hostmeta/generators.py b/federation/hostmeta/generators.py index cfbf47b..621546c 100644 --- a/federation/hostmeta/generators.py +++ b/federation/hostmeta/generators.py @@ -23,16 +23,12 @@ class BaseHostMeta(object): self.xrd = XRD() def render(self): - return self.xrd.to_xml() + return self.xrd.to_xml().toprettyxml(indent=" ", encoding="UTF-8") class DiasporaHostMeta(BaseHostMeta): """Diaspora host-meta. - NOTE! Diaspora .well-known/host-meta seems to define 'encoding="UTF-8"' from server implementation. - The xrd.XRD module does not define this or allow defining it when rendering the XML. This will need to be - fixed if that is a problem to Diaspora or other servers. - Requires keyword args: webfinger_host (str) """ diff --git a/federation/tests/hostmeta/test_generators.py b/federation/tests/hostmeta/test_generators.py index d062840..f0e654f 100644 --- a/federation/tests/hostmeta/test_generators.py +++ b/federation/tests/hostmeta/test_generators.py @@ -2,7 +2,7 @@ import pytest from federation.hostmeta.generators import generate_host_meta -DIASPORA_HOSTMETA = """ +DIASPORA_HOSTMETA = """ @@ -13,7 +13,7 @@ class TestDiasporaHostMetaGenerator(object): def test_generate_valid_host_meta(self): hostmeta = generate_host_meta("diaspora", webfinger_host="https://example.com") - assert hostmeta.toprettyxml(indent=" ") == DIASPORA_HOSTMETA + assert hostmeta.decode("UTF-8") == DIASPORA_HOSTMETA def test_generate_host_meta_requires_webfinger_host(self): with pytest.raises(KeyError):