test: replace false-green checks with behavioral coverage (#6282)
* test: replace false-green checks with behavioral coverage * test: complete behavior-focused audit coverage
This commit is contained in:
1 parent
c7ab7aa6da
commit
74942bd190
91 files changed
+1891
-1391
No files matched your search
@@ -1,21 +1,36 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from nanobot.agent.tools.context import ContextAware, RequestContext
|
||||
from nanobot.agent.tools.base import Tool
|
||||
from nanobot.agent.tools.context import ContextAware, RequestContext, request_context
|
||||
from nanobot.agent.tools.registry import ToolRegistry
|
||||
|
||||
|
||||
class _ContextTool:
|
||||
class _ContextTool(Tool):
|
||||
name = "legacy_context"
|
||||
description = "External-style tool using the legacy context setter."
|
||||
parameters = {"type": "object", "properties": {}}
|
||||
|
||||
def __init__(self):
|
||||
self.last_ctx = None
|
||||
|
||||
def set_context(self, ctx: RequestContext) -> None:
|
||||
self.last_ctx = ctx
|
||||
|
||||
async def execute(self, **kwargs):
|
||||
return self.last_ctx
|
||||
|
||||
def test_context_aware_sets_request_context():
|
||||
|
||||
async def test_registry_injects_request_context_into_legacy_tool():
|
||||
tool = _ContextTool()
|
||||
registry = ToolRegistry()
|
||||
registry.register(tool)
|
||||
ctx = RequestContext(channel="test", chat_id="123", session_key="test:123")
|
||||
tool.set_context(ctx)
|
||||
assert tool.last_ctx.channel == "test"
|
||||
|
||||
with request_context(ctx):
|
||||
result = await registry.execute(tool.name, {})
|
||||
|
||||
assert result is ctx
|
||||
assert tool.last_ctx is ctx
|
||||
|
||||
|
||||
def test_context_tool_is_instance_of_context_aware():
|
||||
|
||||
Reference in new issue
Block a user