fix(tests): Resolve pytest session binding issues and update test cases

- Updated test files to import `AgentSessionLocal` from `advisor_db` instead of directly, preventing session binding to the real database during tests.
- Fixed 6 test cases to use the new login token utility, ensuring consistency across authentication methods.
- Adjusted customer risk codes in `test_convert_confirm.py` to reflect changes in customer classification (C3 to C4).
- Verified that changes resulted in zero database pollution during test runs, maintaining integrity of the testing environment.
- Documented findings and updates in the relevant test logs and memory files, ensuring clarity on the current state of tests and defects.
This commit is contained in:
2026-09-13 23:21:34 +08:00
parent 188bf6a438
commit f856ab4aa6
20 changed files with 86 additions and 92 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
from app.advisor_db import AgentSessionLocal
from app import advisor_db
from app.model.entities_advisor import ScriptTemplate
from app.model.advisor_schemas import ComplianceCheckRequest
from app.service.compliance_check_service import ComplianceCheckService
@@ -98,7 +98,7 @@ def import_templates_from_markdown(
created = 0
updated = 0
with AgentSessionLocal() as session:
with advisor_db.AgentSessionLocal() as session:
for seed_template in templates:
check_result = compliance_service.check_text(
ComplianceCheckRequest(text=seed_template.content, scene=seed_template.scene)