diff options
| author | eunhhu <[email protected]> | 2026-09-30 15:29:36 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-30 15:29:36 +0100 |
| commit | 999439fcb5eeaec6fa5c3d20290e9edf18d70c66 (patch) | |
| tree | e33295c94bb110aab0889010ebf4c0ff35c022ee | |
| parent | ccfd73d6a30e841f40f94bd199fe3ae72fbbad6c (diff) | |
| download | pure-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.
| -rw-r--r-- | docs/design/015-boundary-meaning.md | 1 | ||||
| -rw-r--r-- | tests/check.py | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/docs/design/015-boundary-meaning.md b/docs/design/015-boundary-meaning.md index 41c8c0b..7789919 100644 --- a/docs/design/015-boundary-meaning.md +++ b/docs/design/015-boundary-meaning.md @@ -79,6 +79,7 @@ - 나오는 길: 보기, 질의, 답, 재시작, 체크포인트 뒤의 재시작, 모듈 교체, 두 번 중계한 노드. - 거절할 값 52가지(수, u32, text, bool, 행)가 모든 들어오는 길에서 거절되고, 어디에도 남지 않는다. bool은 JSON, 쿼리, 행에서 거절의 종류까지 본다. +- bool 보기의 글자(`true`)와 bool 인자(`?want=true`, `?want=false`, 그 밖은 400 `invalid`). 전달이 한 번씩, 순서대로 적용되는 것은 링크의 검사들(`server_links_udp_lossy`, `server_links_moved`, `server_upgrade`)과 [012](012-link-protocol.md)이 지킨다. 필드를 이름으로 받는 규칙은 `server_fields`가 지킨다. 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() |
