"""Rewrite advisor sprint tests for merger canonical paths.""" from __future__ import annotations import re from pathlib import Path ROOT = Path(__file__).resolve().parents[2] / "tests" SCHEMA_IMPORTS = ( "ComplianceCheckRequest", "ComplianceRuleCreate", "ComplianceRuleUpdate", "ComplianceCheckResult", "CopyTrackRequest", "TemplateCreate", "KycSessionCreate", "KycChatRequest", "MarketAlertScanRequest", "GuardCheckRequest", ) PATH_MAP = [ ("/api/v1/compliance/check", "/api/advisor-agent/compliance/content-check"), ("/api/v1/compliance/ping", "/api/advisor-agent/compliance/ping"), ("/api/v1/compliance/rules", "/api/advisor-agent/compliance/rules"), ("/api/v1/templates/", "/api/advisor-agent/script-templates/"), ("/api/v1/templates", "/api/advisor-agent/script-templates"), ("/api/v1/market-alerts", "/api/advisor-agent/market-alerts"), ("/api/v1/market/", "/api/advisor-agent/market/"), ("/api/v1/kyc/", "/api/advisor-agent/kyc/"), ("/api/v1/kyc", "/api/advisor-agent/kyc"), ("/api/v1/copy/", "/api/advisor-agent/copy/"), ("/api/v1/guard/", "/api/advisor-agent/guard/"), ("/api/v1/allocation/", "/api/advisor-agent/allocation/"), ("/api/v1/dashboard/", "/api/advisor-agent/dashboard/"), ("/api/v1/admin/audit-logs", "/api/advisor-agent/admin/audit-logs"), ] for path in ROOT.glob("test_sprint*.py"): text = path.read_text(encoding="utf-8") orig = text for old, new in PATH_MAP: text = text.replace(old, new) text = text.replace("from app.model.schemas import", "from app.model.advisor_schemas import") text = text.replace("from app.service.template_service import", "from app.service.script_template_service import") text = text.replace("TemplateService", "ScriptTemplateService") text = re.sub( r'client\.post\(\s*"/api/v1/auth/login",\s*json=\{"username": "advisor_test", "password": "advisor_test"\},?\s*\)', 'client.post("/api/auth/login", json={"actor_id": "STAFF-10086", "token_type": "staff"})', text, ) text = text.replace('"access_token"', '"access_token"') # login response shape differs if text != orig: path.write_text(text, encoding="utf-8") print("updated", path.name)