mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-26 06:16:09 +00:00
feat(cloud): complete Workspace settings navigation
This commit is contained in:
@@ -468,6 +468,22 @@ async def test_cloud_projection_is_selected_explicitly_and_directory_writes_use_
|
||||
cloud_workspace_uuid,
|
||||
}
|
||||
|
||||
class PlanResolver:
|
||||
async def resolve(self, workspace_uuid: str, *, minimum_revision: int = 0):
|
||||
from langbot.pkg.cloud.entitlements import EntitlementSnapshot
|
||||
|
||||
assert workspace_uuid == cloud_workspace_uuid
|
||||
return EntitlementSnapshot(
|
||||
instance_uuid='instance-workspace-api',
|
||||
workspace_uuid=workspace_uuid,
|
||||
entitlement_revision=max(12, minimum_revision),
|
||||
status='active',
|
||||
not_before=1,
|
||||
expires_at=4102444800,
|
||||
plan_name='free',
|
||||
)
|
||||
|
||||
application.entitlement_resolver = PlanResolver()
|
||||
current_response = await client.get(
|
||||
'/api/v1/workspaces/current',
|
||||
headers=_auth(owner_token, cloud_workspace_uuid),
|
||||
@@ -477,6 +493,7 @@ async def test_cloud_projection_is_selected_explicitly_and_directory_writes_use_
|
||||
assert current['workspace']['uuid'] == cloud_workspace_uuid
|
||||
assert current['workspace']['source'] == 'cloud_projection'
|
||||
assert current['placement_generation'] == 12
|
||||
assert current['plan_name'] == 'free'
|
||||
|
||||
create_workspace = await client.post(
|
||||
'/api/v1/workspaces',
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from contextlib import asynccontextmanager
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
@@ -209,6 +210,36 @@ async def test_workspace_selector_requires_membership(collaboration_context):
|
||||
await service.resolve_account_workspace(outsider.uuid, workspace.uuid)
|
||||
|
||||
|
||||
async def test_cloud_member_listing_opens_workspace_uow_when_request_scope_has_closed(
|
||||
collaboration_context,
|
||||
):
|
||||
service, _, session_factory, _, workspace, owner_membership = collaboration_context
|
||||
entered_workspaces: list[str] = []
|
||||
|
||||
@asynccontextmanager
|
||||
async def tenant_uow(workspace_uuid: str):
|
||||
entered_workspaces.append(workspace_uuid)
|
||||
async with session_factory.begin() as session:
|
||||
yield SimpleNamespace(session=session)
|
||||
|
||||
service.ap.persistence_mgr = SimpleNamespace(
|
||||
mode=SimpleNamespace(value='cloud_runtime'),
|
||||
current_session=lambda: None,
|
||||
tenant_uow=tenant_uow,
|
||||
require_current_session=lambda: (_ for _ in ()).throw(
|
||||
AssertionError('list_members must open a Workspace UoW')
|
||||
),
|
||||
get_db_engine=lambda: session_factory.kw['bind'],
|
||||
)
|
||||
|
||||
members = await service.list_members(workspace.uuid, owner_membership)
|
||||
|
||||
assert entered_workspaces == [workspace.uuid]
|
||||
assert [(member.email, member.membership.role) for member in members] == [
|
||||
('owner@example.com', 'owner')
|
||||
]
|
||||
|
||||
|
||||
async def test_cloud_directory_requires_explicit_selector_and_rejects_local_mutation(
|
||||
collaboration_context,
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user