Files
odysseus/tests/test_owned_document_query.py

32 lines
859 B
Python
Raw Normal View History

"""Tests for _owned_document_query owner scoping (src/tool_implementations.py)."""
refactor(tools): extract document tools to handle registry (#3666) * feat(tools): add document management tool handlers to the agent_tools module * feat(tools): extraced document tools for create, update, edit, suggest, and manage from tool_implementations.py * feat(tests): refactor document tool tests to use TOOL_HANDLERS and document_tools * refactor(tools): add document tool dispatcher and updated tool calling path * refactor(tools): remove duplicated document management functions * refactor(tools): removing unused functions and adding new import paths * refactor(tools): update document tool execute methods to use context dictionary * refactor(tests): update import paths for document tools in test files * refactor(tests): update owner parameter format in document management tests * refactor(tests): update import path for _owned_document_query * feat(tools): add document management tool handlers to the agent_tools module * feat(tools): extraced document tools for create, update, edit, suggest, and manage from tool_implementations.py * feat(tests): refactor document tool tests to use TOOL_HANDLERS and document_tools * refactor(tools): add document tool dispatcher and updated tool calling path * refactor(tools): remove duplicated document management functions * refactor(tools): removing unused functions and adding new import paths * refactor(tools): update document tool execute methods to use context dictionary * refactor(tests): update import paths for document tools in test files * refactor(tests): update owner parameter format in document management tests * refactor(tests): update import path for _owned_document_query * refactor: update import paths for document tools * fix(tests): correct source path for document ID test
2026-06-10 09:41:52 +01:00
from src.agent_tools.document_tools import _owned_document_query
class _FakeQuery:
def __init__(self):
self.filter_args = []
def filter(self, *args):
self.filter_args.append(args)
return self
class _Doc:
owner = "owner-column-sentinel"
def test_owner_none_does_not_pass_python_false():
q = _FakeQuery()
_owned_document_query(q, _Doc, None)
arg = q.filter_args[-1][0]
# The old code passed the bare Python bool False, which SQLAlchemy 2.x
# rejects; the fix passes a SQL false() literal instead.
assert arg is not False
assert arg is not None
def test_owner_set_filters_by_owner():
q = _FakeQuery()
_owned_document_query(q, _Doc, "alice")
assert q.filter_args, "should apply an owner filter"