Skip to content

Commit

Permalink
updated tests to use snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
jonchun committed Feb 12, 2025
1 parent 6547863 commit a0b36dd
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,14 @@ def y_tool(y: str) -> None:
agent = Agent('test', tools=[Tool(x_tool, function_schema=y_fs)])

# make sure the function schema for y_tool is used instead of the default of x_tool.
assert 'x' not in agent._function_tools['x_tool']._parameters_json_schema['properties']
assert 'y' in agent._function_tools['x_tool']._parameters_json_schema['properties']
assert agent._function_tools['x_tool']._parameters_json_schema == snapshot(
{
'additionalProperties': False,
'properties': {'y': {'title': 'Y', 'type': 'string'}},
'required': ['y'],
'type': 'object',
}
)


def test_init_tool_ctx_with_function_schema():
Expand All @@ -374,9 +380,14 @@ def y_tool(ctx: RunContext[int], y: str) -> None:
)
agent = Agent('test', tools=[Tool(x_tool, function_schema=y_fs, takes_ctx=True)], deps_type=int)

# make sure the function schema for y_tool is used instead of the default of x_tool.
assert 'x' not in agent._function_tools['x_tool']._parameters_json_schema['properties']
assert 'y' in agent._function_tools['x_tool']._parameters_json_schema['properties']
assert agent._function_tools['x_tool']._parameters_json_schema == snapshot(
{
'additionalProperties': False,
'properties': {'y': {'title': 'Y', 'type': 'string'}},
'required': ['y'],
'type': 'object',
}
)


def ctx_tool(ctx: RunContext[int], x: int) -> int:
Expand Down

0 comments on commit a0b36dd

Please sign in to comment.