test: rename SearchSpace -> Workspace across tests + fixtures (Phase 2 Wave F)

Apply the same rename to surfsense_backend/tests: workspace_id fields/vars,
Workspace* classes/schemas, table name searchspaces -> workspaces in raw SQL,
and the API URL spellings -> /workspaces. Preserves the carve-out wire literals
tests assert (Celery task names, OTel key "search_space.id").
This commit is contained in:
CREDO23 2026-06-26 18:36:46 +02:00
parent 56826a63bc
commit ca9bd28934
124 changed files with 1269 additions and 1269 deletions

View file

@ -39,11 +39,11 @@ pytestmark = pytest.mark.unit
def _make_middleware(mode: FilesystemMode = FilesystemMode.CLOUD):
selection = FilesystemSelection(mode=mode)
resolver = build_backend_resolver(selection, search_space_id=1)
resolver = build_backend_resolver(selection, workspace_id=1)
return build_filesystem_mw(
backend_resolver=resolver,
filesystem_mode=mode,
search_space_id=1,
workspace_id=1,
user_id="00000000-0000-0000-0000-000000000001",
thread_id=1,
)
@ -290,7 +290,7 @@ class TestKBPostgresBackendDeleteFilter:
def _make_backend(self, state: dict[str, Any]) -> KBPostgresBackend:
runtime = SimpleNamespace(state=state)
return KBPostgresBackend(search_space_id=1, runtime=runtime)
return KBPostgresBackend(workspace_id=1, runtime=runtime)
def test_pending_filesystem_view_returns_deleted_paths(self):
backend = self._make_backend(

View file

@ -38,16 +38,16 @@ def test_backend_resolver_returns_multi_root_backend_for_single_root(tmp_path: P
def test_backend_resolver_uses_cloud_mode_by_default():
resolver = build_backend_resolver(FilesystemSelection())
backend = resolver(_RuntimeStub())
# When no search_space_id is provided we fall back to StateBackend so
# When no workspace_id is provided we fall back to StateBackend so
# sub-agents / tests without DB access still work.
assert backend.__class__.__name__ == "StateBackend"
def test_backend_resolver_uses_kb_postgres_in_cloud_with_search_space():
resolver = build_backend_resolver(FilesystemSelection(), search_space_id=42)
def test_backend_resolver_uses_kb_postgres_in_cloud_with_workspace():
resolver = build_backend_resolver(FilesystemSelection(), workspace_id=42)
backend = resolver(_RuntimeStub())
assert backend.__class__.__name__ == "KBPostgresBackend"
assert backend.search_space_id == 42
assert backend.workspace_id == 42
def test_backend_resolver_returns_multi_root_backend_for_multiple_roots(tmp_path: Path):

View file

@ -92,7 +92,7 @@ async def test_create_document_allows_identical_content_at_different_paths() ->
session, # type: ignore[arg-type]
virtual_path="/documents/a/notes.md",
content=content,
search_space_id=42,
workspace_id=42,
created_by_id="user-1",
)
assert isinstance(first, Document)
@ -104,7 +104,7 @@ async def test_create_document_allows_identical_content_at_different_paths() ->
session, # type: ignore[arg-type]
virtual_path="/documents/b/notes-copy.md",
content=content,
search_space_id=42,
workspace_id=42,
created_by_id="user-1",
)
assert isinstance(second, Document)
@ -121,7 +121,7 @@ async def test_create_document_still_rejects_path_collision() -> None:
"""Path uniqueness remains the hard invariant.
If ``unique_identifier_hash`` already points at an existing row in
the same search space, the create call must raise ``ValueError``
the same workspace, the create call must raise ``ValueError``
with a clear message matching the behavior the commit loop relies
on to upsert via the existing-row code path.
"""
@ -137,7 +137,7 @@ async def test_create_document_still_rejects_path_collision() -> None:
session, # type: ignore[arg-type]
virtual_path="/documents/notes.md",
content="anything",
search_space_id=42,
workspace_id=42,
created_by_id="user-1",
)
@ -160,7 +160,7 @@ async def test_create_document_does_not_query_for_content_hash_collision(
session, # type: ignore[arg-type]
virtual_path="/documents/notes.md",
content="hello",
search_space_id=42,
workspace_id=42,
created_by_id="user-1",
)
# Path-collision SELECT only. No content_hash SELECT.

View file

@ -217,7 +217,7 @@ async def test_pre_write_snapshot_defers_dispatch_when_list_provided(
session, # type: ignore[arg-type]
doc=doc,
action_id=42,
search_space_id=1,
workspace_id=1,
turn_id="t-1",
deferred_dispatches=deferred,
)
@ -262,7 +262,7 @@ async def test_pre_write_snapshot_dispatches_inline_when_list_omitted(
session, # type: ignore[arg-type]
doc=doc,
action_id=88,
search_space_id=1,
workspace_id=1,
turn_id="t-1",
# No deferred_dispatches arg — fall back to inline dispatch.
)
@ -302,7 +302,7 @@ async def test_pre_mkdir_snapshot_defers_dispatch_when_list_provided(
session, # type: ignore[arg-type]
folder=folder,
action_id=55,
search_space_id=1,
workspace_id=1,
turn_id="t-1",
deferred_dispatches=deferred,
)

View file

@ -28,7 +28,7 @@ pytestmark = pytest.mark.unit
def _backend(state: dict) -> KBPostgresBackend:
return KBPostgresBackend(search_space_id=1, runtime=SimpleNamespace(state=state))
return KBPostgresBackend(workspace_id=1, runtime=SimpleNamespace(state=state))
def test_render_full_document_uses_full_view_and_registers() -> None:

View file

@ -101,7 +101,7 @@ class TestFormatTreeRendering:
docs = [_Row(**spec) for spec in doc_specs]
mw = KnowledgeTreeMiddleware(
search_space_id=1,
workspace_id=1,
filesystem_mode=None, # type: ignore[arg-type]
)
return mw._format_tree(index, docs)