Private
Public Access
0
0
Files
manual_slop/tests/test_bias_models.py
T
ed 8f11340b38 refactor(consumers): migrate 85 'from src.models import' sites to direct subsystem imports
Per post_module_taxonomy_de_cruft_20260627 Phase 2 (FR7). Each
'from src.models import X' for a moved class is rewritten to
'from src.<destination> import X':

  Ticket, Track, WorkerContext, TrackState, TrackMetadata,
    ThinkingSegment, EMPTY_TRACK_STATE            -> src.mma
  ProjectContext, ProjectMeta, ProjectOutput, ProjectFiles,
    ProjectScreenshots, ProjectDiscussion, EMPTY_PROJECT_CONTEXT -> src.project
  FileItem, Preset, ContextPreset, ContextFileEntry,
    NamedViewPreset                                -> src.project_files
  Tool, ToolPreset                                 -> src.tool_presets
  BiasProfile                                      -> src.tool_bias
  TextEditorConfig, ExternalEditorConfig,
    EMPTY_TEXT_EDITOR_CONFIG                       -> src.external_editor
  Persona                                          -> src.personas
  WorkspaceProfile                                -> src.workspace_manager
  MCPServerConfig, MCPConfiguration, VectorStoreConfig,
    RAGConfig, load_mcp_config                      -> src.mcp_client

NOT touched (kept on src.models; Phase 3 or Phase 4 will move them):
  GenerateRequest, ConfirmRequest, DEFAULT_TOOL_CATEGORIES, Metadata, PROVIDERS

Migration was performed by the one-time script
scripts/tier2/artifacts/post_module_taxonomy_de_cruft_20260627/migrate_imports.py
which uses a class-to-module map and re.sub() to rewrite each
'from src.models import X' line.

Total: 85 import lines rewritten across 71 files.

Note: this commit depends on the v2 SHIPPED work
(origin/tier2/module_taxonomy_refactor_20260627) being merged into
this branch NEXT. On master (without the v2 SHIPPED commits), the
destination modules do not exist and these imports would fail.
2026-06-26 13:34:03 -04:00

48 lines
1.7 KiB
Python

import pytest
from src.tool_bias import BiasProfile
from src.tool_presets import Tool, ToolPreset
def test_tool_model():
tool = Tool(name="read_file", weight=5, parameter_bias={"path": "preferred"})
data = tool.to_dict()
assert data["name"] == "read_file"
assert data["weight"] == 5
assert data["parameter_bias"]["path"] == "preferred"
tool2 = Tool.from_dict(data)
assert tool2.name == "read_file"
assert tool2.weight == 5
assert tool2.parameter_bias["path"] == "preferred"
def test_tool_preset_extension():
# Verify that ToolPreset correctly parses and serializes Tool objects
tool_data = {"name": "read_file", "weight": 4, "parameter_bias": {"path": "high"}}
raw_data = {"categories": {"General": [tool_data]}}
# Test parsing via from_dict
preset = ToolPreset.from_dict("test", raw_data)
assert isinstance(preset.categories["General"][0], Tool)
assert preset.categories["General"][0].weight == 4
# Test serialization
data = preset.to_dict()
assert data["categories"]["General"][0]["weight"] == 4
assert data["categories"]["General"][0]["name"] == "read_file"
def test_bias_profile_model():
profile = BiasProfile(
name="Execution-Focused",
tool_weights={"run_powershell": 5},
category_multipliers={"Surgical": 1.5}
)
data = profile.to_dict()
assert data["tool_weights"]["run_powershell"] == 5
assert data["category_multipliers"]["Surgical"] == 1.5
# BiasProfile.from_dict expects 'name' inside the dict as well if coming from load_all_bias_profiles
data["name"] = "Execution-Focused"
profile2 = BiasProfile.from_dict(data)
assert profile2.name == "Execution-Focused"
assert profile2.tool_weights["run_powershell"] == 5
assert profile2.category_multipliers["Surgical"] == 1.5