Files
Artemis-Eapil/tests/tools/diagnoser/test_diagnoser_tools.py
T
chenmingxuan 2ddec53954
CI / Python 3.12 / ubuntu-latest (push) Canceled after 0s
CI / Python 3.12 / windows-latest (push) Canceled after 0s
CI / Frontend tests and production build (push) Canceled after 0s
CI / Build and smoke-test Python packages (push) Canceled after 0s
feat: add Chinese UI, Responses models, and mirrored Windows setup
Localize the web console and persist custom model and capability settings.
Use OpenAI Responses exclusively and move runtime limits into environment configuration.
Bootstrap uv and the virtual environment on Windows, support optional China mirrors,
and package source distributions without environments, build output, or credentials.

Update regression tests and repository quality checks for the new behavior.
2026-09-22 19:16:17 +08:00

114 lines
4.0 KiB
Python

# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from artemis.tools.diagnoser_submit_answer_tool import get_submit_answer_tool
def test_diagnoser_submit_answer_tool(artemis_context):
tool = get_submit_answer_tool(artemis_context)
# Execute the tool with some typical payload
result = tool.invoke(
{
"analysis": "The problem is caused by a network timeout.",
"actionable_steps": ["Check network connection", "Restart the server"],
}
)
# Assert that the tool executes without raising errors and produces expected output structure
assert result == "Answer submitted successfully."
assert "error" not in result.lower()
def test_submit_answer_tool_subclass():
"""Verify SubmitAnswerTool is an ArtemisTool subclass."""
from artemis.tools.base import ArtemisTool
from artemis.tools.diagnoser_submit_answer_tool import (
DiagnoserSubmitAnswerTool,
SubmitAnswer,
SubmitAnswerArgs,
SubmitAnswerTool,
submit_answer,
)
assert issubclass(SubmitAnswerTool, ArtemisTool)
assert issubclass(SubmitAnswer, ArtemisTool)
assert issubclass(DiagnoserSubmitAnswerTool, ArtemisTool)
assert isinstance(submit_answer, ArtemisTool)
assert isinstance(submit_answer, SubmitAnswerTool)
assert submit_answer.name == "submit_answer"
assert submit_answer.category == "custom"
assert submit_answer.args_schema == SubmitAnswerArgs
# GenAI FunctionDeclaration export
declaration = submit_answer.to_tool_declaration()
assert declaration.name == "submit_answer"
assert "analysis" in declaration.parameters["properties"]
assert "actionable_steps" in declaration.parameters["properties"]
def test_ask_diagnoser_tool_subclass():
"""Verify AskDiagnoserTool is an ArtemisTool subclass."""
from artemis.tools.base import ArtemisTool
from artemis.tools.diagnostic_tool import (
AskDiagnoser,
AskDiagnoserArgs,
AskDiagnoserTool,
DiagnosticTool,
ask_diagnoser,
)
assert issubclass(AskDiagnoserTool, ArtemisTool)
assert issubclass(AskDiagnoser, ArtemisTool)
assert issubclass(DiagnosticTool, ArtemisTool)
assert isinstance(ask_diagnoser, ArtemisTool)
assert isinstance(ask_diagnoser, AskDiagnoserTool)
assert ask_diagnoser.name == "ask_diagnoser"
assert ask_diagnoser.category == "custom"
assert ask_diagnoser.args_schema == AskDiagnoserArgs
# GenAI FunctionDeclaration export
declaration = ask_diagnoser.to_tool_declaration()
assert declaration.name == "ask_diagnoser"
assert "query" in declaration.parameters["properties"]
def test_analyze_logs_tool_subclass():
"""Verify AnalyzeLogsTool is an ArtemisTool subclass."""
from artemis.tools.base import ArtemisTool
from artemis.tools.log_tool import (
AnalyzeLogs,
AnalyzeLogsArgs,
AnalyzeLogsTool,
LogTool,
analyze_logs,
)
assert issubclass(AnalyzeLogsTool, ArtemisTool)
assert issubclass(AnalyzeLogs, ArtemisTool)
assert issubclass(LogTool, ArtemisTool)
assert isinstance(analyze_logs, ArtemisTool)
assert isinstance(analyze_logs, AnalyzeLogsTool)
assert analyze_logs.name == "analyze_logs"
assert analyze_logs.category == "custom"
assert analyze_logs.args_schema == AnalyzeLogsArgs
# GenAI FunctionDeclaration export
declaration = analyze_logs.to_tool_declaration()
assert declaration.name == "analyze_logs"
assert "specific_query" in declaration.parameters["properties"]