aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_groups_self_service.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_groups_self_service.py')
-rw-r--r--packages/meshbay-hub/tests/test_groups_self_service.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/packages/meshbay-hub/tests/test_groups_self_service.py b/packages/meshbay-hub/tests/test_groups_self_service.py
index a60209d..3202658 100644
--- a/packages/meshbay-hub/tests/test_groups_self_service.py
+++ b/packages/meshbay-hub/tests/test_groups_self_service.py
@@ -40,6 +40,16 @@ async def _create_group(client, token, name="test-group", visibility="public",
return r.json()["group_id"]
+
+async def _mark_hosted(db_session, *group_ids):
+ """Pretend a node announced these groups, as /v1/nodes/ws would."""
+ from datetime import datetime, timezone
+ from meshbay_hub.db.models import Group
+ for gid in group_ids:
+ (await db_session.get(Group, gid)).hosted_at = datetime.now(timezone.utc)
+ await db_session.commit()
+
+
@pytest.mark.asyncio
async def test_create_group(client):
await _register(client, "alice", email="a@x.com")
@@ -73,8 +83,11 @@ async def test_join_open_group(client):
async def test_join_invite_group_rejected(client):
await _register(client, "alice", email="a@x.com")
alice_token = await _login(client, "alice")
+ # Private: invite-only is refused on a public group now, since a group
+ # everyone can find and nobody can enter is a dead end. What is under test
+ # here — /join refusing a group that is not open — is unchanged.
gid = await _create_group(client, alice_token, "invite-group",
- join_policy="invite")
+ visibility="private", join_policy="invite")
await _register(client, "bob", email="b@x.com")
bob_token = await _login(client, "bob")
@@ -132,11 +145,14 @@ async def test_group_members_non_member_denied(client):
@pytest.mark.asyncio
-async def test_group_search(client):
+async def test_group_search(client, db_session):
await _register(client, "alice", email="a@x.com")
token = await _login(client, "alice")
- await _create_group(client, token, "alpha-team")
- await _create_group(client, token, "beta-team")
+ a = await _create_group(client, token, "alpha-team")
+ b = await _create_group(client, token, "beta-team")
+ # The directory shows groups a node has announced. Marked here so this test
+ # exercises the search filter rather than the hosting one.
+ await _mark_hosted(db_session, a, b)
r = await client.get("/v1/groups?q=alpha")
assert r.status_code == 200