aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-30 15:29:36 +0100
committereunhhu <[email protected]>2026-09-30 15:29:36 +0100
commit999439fcb5eeaec6fa5c3d20290e9edf18d70c66 (patch)
treee33295c94bb110aab0889010ebf4c0ff35c022ee /tests
parentccfd73d6a30e841f40f94bd199fe3ae72fbbad6c (diff)
downloadpure-999439fcb5eeaec6fa5c3d20290e9edf18d70c66.tar.gz
pure-999439fcb5eeaec6fa5c3d20290e9edf18d70c66.zip
Check a bool view's text and a bool argument over HTTP
server_meaning's origin gains a bool view and a view with a bool argument: GET /views/any_ok answers true as text, with_ok?want=true and ?want=false count the kept values each way, and 1, True or nothing for the argument is 400 invalid.
Diffstat (limited to 'tests')
-rw-r--r--tests/check.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/check.py b/tests/check.py
index 117beff..0c16802 100644
--- a/tests/check.py
+++ b/tests/check.py
@@ -3372,6 +3372,8 @@ on put_plain {
on touch {
kept[touch.id].t = touch.t
}
+view any_ok = count(k in kept where k.ok) > 0
+view with_ok(want: bool) = count(k in kept where k.ok == want)
""" + MEANING_ROWS
# B: A's sends over the link, taken by name (fields in another order, u a number), kept and sent on over HTTP.
MEANING_MIRROR = MEANING_KEPT + """input passed = message {
@@ -3602,6 +3604,14 @@ def server_meaning(aup, pure, work):
for where, found in exits.items():
wrong = differing(found, expected)
assert not wrong, (where, wrong[:3])
+ # A bool view is true or false as text; a bool argument is true or false in a query, nothing else.
+ a = hosts['a'].port
+ assert http(a, 'GET', '/views/any_ok')[::3] == (200, b'true')
+ oks = sum(1 for value in expected.values() if value[5])
+ assert http(a, 'GET', '/views/with_ok?want=true')[::3] == (200, str(oks).encode())
+ assert http(a, 'GET', '/views/with_ok?want=false')[::3] == (200, str(len(expected) - oks).encode())
+ for bad in ('1', 'True', ''):
+ assert http(a, 'GET', f'/views/with_ok?want={bad}')[:2] == (400, 'invalid'), bad
finally:
for host in hosts.values():
host.stop()