Files
AstrBot/tests/test_agent.py
LIghtJUNction dcaaf6286a test: comprehensive test coverage and type fixes
- Add 100+ new test files covering provider sources, platform adapters,
  agent runners, star/plugin system, knowledge base, core utils,
  pipeline, computer tools, builtin commands, and dashboard routes
- Fix Python type errors in sqlite.py (col() wrappers for SQLModel),
  astr_agent_tool_exec, core_lifecycle, star context/manager
- Fix TypeScript strict mode errors across 30+ dashboard Vue files
- Add import smoke tests, auth roundtrip, startup tests
- Add compile-all check and CLI entry test for AUR compatibility
- Restore BotMessageAccumulator and helpers lost in merge
2026-04-29 06:29:56 +08:00

49 lines
1.6 KiB
Python

"""Import smoke tests for Agent dataclass."""
import pytest
from astrbot.core.agent.agent import Agent
class TestAgentImport:
"""Verify Agent dataclass can be imported and instantiated."""
def test_class_importable(self):
"""Agent should be importable."""
assert Agent is not None
def test_instantiation_with_name_only(self):
"""Agent should be instantiatable with just a name."""
agent = Agent(name="test_agent")
assert isinstance(agent, Agent)
assert agent.name == "test_agent"
def test_instantiation_with_all_fields(self):
"""Agent should accept all optional fields."""
agent = Agent(
name="full_agent",
instructions="You are a test agent.",
tools=["tool1", "tool2"],
# run_hooks and begin_dialogs can be None for this test
)
assert agent.name == "full_agent"
assert agent.instructions == "You are a test agent."
assert agent.tools == ["tool1", "tool2"]
assert agent.run_hooks is None
assert agent.begin_dialogs is None
def test_is_dataclass(self):
"""Agent should be a dataclass."""
from dataclasses import dataclass
# Check it has the dataclass decorator by inspecting __dataclass_fields__
assert hasattr(Agent, "__dataclass_fields__")
def test_defaults(self):
"""Agent fields should have correct defaults."""
agent = Agent(name="defaults_test")
assert agent.instructions is None
assert agent.tools is None
assert agent.run_hooks is None
assert agent.begin_dialogs is None