about summary refs log tree commit diff
path: root/tst/test_listen.py
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-06-20 16:43:30 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-06-20 17:54:35 +0900
commitb102f8e660c40f074419a03c7b0615b5cbead0bb (patch)
treefaddefbfc4b806f59a66f1ae22ceb9f16aecee3f /tst/test_listen.py
parent01b0e90c621606071e20534c93f5299cbfcacda3 (diff)
downloadscadere-b102f8e660c40f074419a03c7b0615b5cbead0bb.tar.gz
Add Last-Modified header to HTTP responses
Diffstat (limited to 'tst/test_listen.py')
-rw-r--r--tst/test_listen.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tst/test_listen.py b/tst/test_listen.py
index bab9072..61929c8 100644
--- a/tst/test_listen.py
+++ b/tst/test_listen.py
@@ -6,7 +6,7 @@
 from asyncio import open_unix_connection, start_unix_server
 from contextlib import asynccontextmanager, contextmanager
 from copy import deepcopy
-from datetime import datetime
+from datetime import datetime, timezone
 from email.parser import BytesHeaderParser
 from functools import partial
 from http import HTTPMethod
@@ -19,7 +19,7 @@ from xml.etree.ElementTree import (XML, XMLParser, indent,
 
 from hypothesis import HealthCheck, given, settings
 from hypothesis.strategies import (booleans, composite, data,
-                                   datetimes, from_type, integers,
+                                   datetimes, from_type, integers, just,
                                    sampled_from, sets, text, uuids)
 from hypothesis.provisional import domains, urls
 from pytest import raises
@@ -30,6 +30,7 @@ from scadere.listen import (handle, is_subdomain, path, parse_summary,
 
 ATOM_NAMESPACES = {'': 'http://www.w3.org/2005/Atom'}
 XHTML_NAMESPACES = {'': 'http://www.w3.org/1999/xhtml'}
+UTC_DATETIMES = datetimes(timezones=just(timezone.utc))
 
 
 def ports():
@@ -84,8 +85,8 @@ def test_xml_unsupported_type(tag, child):
 def certificates(draw):
     """Return a Hypothesis strategy for certificate summaries."""
     valid = draw(booleans())
-    not_before = draw(datetimes()).isoformat() if valid else 'N/A'
-    not_after = draw(datetimes()).isoformat()
+    not_before = draw(UTC_DATETIMES).isoformat()
+    not_after = draw(UTC_DATETIMES).isoformat() if valid else 'N/A'
     hostname = draw(domains())
     port = draw(ports())
     number = draw(serials()) if valid else draw(uuids(version=4)).int
@@ -210,7 +211,8 @@ def unique_netlocs(summaries):
 @given(urls().filter(is_base_url).filter(has_usual_path),
        sets(certificates(), min_size=1).map(unique_netlocs),
        text().filter(printable))
-@settings(suppress_health_check=[HealthCheck.too_slow])
+@settings(suppress_health_check=(HealthCheck.filter_too_much,
+                                 HealthCheck.too_slow))
 async def test_content(base_url, certs, title):
     base_path = urlsplit(base_url).path
     with tmp_cert_file(certs) as cert_file: