about summary refs log tree commit diff
path: root/tst/test_listen.py
diff options
context:
space:
mode:
Diffstat (limited to 'tst/test_listen.py')
-rw-r--r--tst/test_listen.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tst/test_listen.py b/tst/test_listen.py
index c6d9cd4..3737baa 100644
--- a/tst/test_listen.py
+++ b/tst/test_listen.py
@@ -36,7 +36,8 @@ from hypothesis.strategies import (builds, composite, data,
                                    datetimes, integers, lists, text)
 from hypothesis.provisional import domains, urls
 
-from scadere.listen import body, entry, handle, path, with_trailing_slash, xml
+from scadere.listen import (body, entry, handle, is_subdomain,
+                            path, with_trailing_slash, xml)
 
 ATOM_NAMESPACES = {'': 'http://www.w3.org/2005/Atom'}
 XHTML_NAMESPACES = {'': 'http://www.w3.org/1999/xhtml'}
@@ -119,6 +120,19 @@ def test_atom_entry(base_url, hostname, port,
 </entry>'''
 
 
+@given(domains(), lists(domains()))
+def test_is_subdomain(subject, objects):
+    if not objects:
+        assert is_subdomain(subject, objects)
+    elif is_subdomain(subject, objects):
+        assert any(child == '' or child.endswith('.')
+                   for child in map(subject.removesuffix, objects))
+    else:
+        for obj in objects:
+            assert (not subject.endswith(obj)
+                    or not subject.removesuffix(obj).endswith('.'))
+
+
 @composite
 def certificates(draw):
     """Return a Hypothesis strategy for certificate summaries."""