Make hostmeta generator return string not XML Document

merge-requests/130/head
Jason Robinson 2015-07-12 02:02:44 +03:00
rodzic f61c2b576f
commit f359ac8247
2 zmienionych plików z 3 dodań i 7 usunięć

Wyświetl plik

@ -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)
"""

Wyświetl plik

@ -2,7 +2,7 @@ import pytest
from federation.hostmeta.generators import generate_host_meta
DIASPORA_HOSTMETA = """<?xml version="1.0" ?>
DIASPORA_HOSTMETA = """<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" template="https://example.com/webfinger?q={uri}" type="application/xrd+xml"/>
</XRD>
@ -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):