mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-11 21:17:25 -04:00
feat(worker): add _add_job_warnings helper method
Delegate to JobManager.add_job_warnings for storing warnings. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -282,6 +282,10 @@ class SimulationWorker:
|
|||||||
|
|
||||||
return dates_to_process
|
return dates_to_process
|
||||||
|
|
||||||
|
def _add_job_warnings(self, warnings: List[str]) -> None:
|
||||||
|
"""Store warnings in job metadata."""
|
||||||
|
self.job_manager.add_job_warnings(self.job_id, warnings)
|
||||||
|
|
||||||
def get_job_info(self) -> Dict[str, Any]:
|
def get_job_info(self) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Get job information.
|
Get job information.
|
||||||
|
|||||||
@@ -382,5 +382,35 @@ class TestSimulationWorkerHelperMethods:
|
|||||||
# Should exclude completed date
|
# Should exclude completed date
|
||||||
assert result == ["2025-10-02", "2025-10-03"]
|
assert result == ["2025-10-02", "2025-10-03"]
|
||||||
|
|
||||||
|
def test_add_job_warnings(self, clean_db):
|
||||||
|
"""Test adding warnings to job via worker."""
|
||||||
|
from api.simulation_worker import SimulationWorker
|
||||||
|
from api.job_manager import JobManager
|
||||||
|
from api.database import initialize_database
|
||||||
|
import json
|
||||||
|
|
||||||
|
db_path = clean_db
|
||||||
|
initialize_database(db_path)
|
||||||
|
job_manager = JobManager(db_path=db_path)
|
||||||
|
|
||||||
|
# Create job
|
||||||
|
job_id = job_manager.create_job(
|
||||||
|
config_path="config.json",
|
||||||
|
date_range=["2025-10-01"],
|
||||||
|
models=["gpt-5"]
|
||||||
|
)
|
||||||
|
|
||||||
|
worker = SimulationWorker(job_id=job_id, db_path=db_path)
|
||||||
|
|
||||||
|
# Add warnings
|
||||||
|
warnings = ["Warning 1", "Warning 2"]
|
||||||
|
worker._add_job_warnings(warnings)
|
||||||
|
|
||||||
|
# Verify warnings were stored
|
||||||
|
job = job_manager.get_job(job_id)
|
||||||
|
assert job["warnings"] is not None
|
||||||
|
stored_warnings = json.loads(job["warnings"])
|
||||||
|
assert stored_warnings == warnings
|
||||||
|
|
||||||
|
|
||||||
# Coverage target: 90%+ for api/simulation_worker.py
|
# Coverage target: 90%+ for api/simulation_worker.py
|
||||||
|
|||||||
Reference in New Issue
Block a user