about summary refs log tree commit diff
path: root/tst
diff options
context:
space:
mode:
Diffstat (limited to 'tst')
-rw-r--r--tst/test_listen.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tst/test_listen.py b/tst/test_listen.py
index 61929c8..d13475d 100644
--- a/tst/test_listen.py
+++ b/tst/test_listen.py
@@ -24,6 +24,7 @@ from hypothesis.strategies import (booleans, composite, data,
 from hypothesis.provisional import domains, urls
 from pytest import raises
 
+from scadere import __version__, atom2xhtml
 from scadere.check import base64_from_str, printable
 from scadere.listen import (handle, is_subdomain, path, parse_summary,
                             str_from_base64, with_trailing_slash, xml)
@@ -172,6 +173,21 @@ async def fetch_xml(socket, url, content_type):
         return XML(content.decode(), xml_parser)
 
 
+async def check_atom2xhtml(socket, url):
+    """Check if socket serves atom2xhtml stylesheet at given HTTP URL."""
+    header_parser = BytesHeaderParser()
+    async with connect(socket) as (reader, writer):
+        await write_request(writer, f'GET {url} HTTP/1.1\r\n')
+        status = await reader.readuntil(b'\r\n')
+        assert status == b'HTTP/1.1 200 OK\r\n'
+        headers_bytes = await reader.readuntil(b'\r\n\r\n')
+        headers = header_parser.parsebytes(headers_bytes)
+        assert headers['Content-Type'] == 'application/xslt+xml'
+        content = await reader.read()
+        assert len(content) == int(headers['Content-Length'])
+        assert content == atom2xhtml()
+
+
 def equal_xml(a, b):
     """Check if the two XML elements are equal."""
     a_copy, b_copy = deepcopy(a), deepcopy(b)
@@ -181,8 +197,9 @@ def equal_xml(a, b):
 
 
 async def check_feed(socket, base_url):
-    """Check the Atom feed at the given path and its entry pages."""
+    """Check the Atom feed, its stylesheet, and entry pages."""
     feed = await fetch_xml(socket, base_url, 'application/atom+xml')
+    await check_atom2xhtml(socket, f'{base_url}{__version__}.xslt')
     for entry in feed.findall('entry', ATOM_NAMESPACES):
         link = entry.find('link', ATOM_NAMESPACES).attrib
         assert link['rel'] == 'alternate'