36 lines
1.6 KiB
Python
36 lines
1.6 KiB
Python
"""loomio — §4.3 create-an-object + read-it-back for a group.
|
|
|
|
Creates a verified user and a public/open group through the app's own Rails console (the same
|
|
`Group`/`Membership` path the API controller uses — STYLE §1 option 2), then reads the group back
|
|
ANONYMOUSLY through the public HTTP API (`GET /api/v1/groups/<key>`), a different path.
|
|
|
|
Non-vacuous: if DB persistence, the public-group ability rule (`Ability::Group#show` requires
|
|
`is_visible_to_public`), FriendlyId key lookup, or group serialization is broken, this fails even
|
|
though the landing page and health endpoint still answer. The group name/handle are run-scoped.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.dirname(__file__))
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
|
|
import _loomio # noqa: E402
|
|
from harness import http as harness_http # noqa: E402
|
|
|
|
|
|
def test_public_group_roundtrip(live_app):
|
|
group_key = _loomio.ensure_group(live_app)
|
|
|
|
url = f"https://{live_app}/api/v1/groups/{group_key}"
|
|
status, body = harness_http.retry_http_get(url, expect_status=200, max_wait=60, interval=3)
|
|
assert status == 200, f"anonymous GET {url} HTTP {status} (public group not readable)"
|
|
group = _loomio.unwrap(body, "groups")
|
|
assert group.get("handle") == _loomio.GROUP_HANDLE, (
|
|
f"group handle did not round-trip: sent {_loomio.GROUP_HANDLE!r}, got {group.get('handle')!r}"
|
|
)
|
|
assert group.get("name") == _loomio.GROUP_NAME, (
|
|
f"group name did not round-trip: sent {_loomio.GROUP_NAME!r}, got {group.get('name')!r}"
|
|
)
|