NODEDC_1C/tests/test_domain_case_loop.py

45 lines
1.4 KiB
Python

from __future__ import annotations
from scripts.domain_case_loop import carry_forward_analysis_context, merge_scenario_date_scope
def test_carry_forward_analysis_context_preserves_followup_anchor() -> None:
scenario_state = {
"semantic_memory": {
"date_scope": {"as_of_date": "2020-03-31"},
}
}
analysis_context = {"as_of_date": "2026-04-13", "source": "current_analysis"}
carried = carry_forward_analysis_context(scenario_state, analysis_context)
assert carried["as_of_date"] == "2026-04-13"
assert carried["source"] == "current_analysis"
def test_carry_forward_analysis_context_fills_missing_anchor() -> None:
scenario_state = {
"semantic_memory": {
"date_scope": {"as_of_date": "2020-03-31"},
}
}
carried = carry_forward_analysis_context(scenario_state, {})
assert carried["as_of_date"] == "2020-03-31"
assert carried["source"] == "scenario_state_carryover"
def test_merge_scenario_date_scope_preserves_historical_anchor_on_followup() -> None:
previous_date_scope = {"as_of_date": "2020-03-31", "source": "exact_anchor"}
current_date_scope = {"as_of_date": "2026-04-13", "source": "current_analysis"}
merged = merge_scenario_date_scope(
previous_date_scope,
current_date_scope,
depends_on=["step_01_anchor"],
)
assert merged["as_of_date"] == "2020-03-31"
assert merged["source"] == "current_analysis"