|
9 | 9 | format_public_market_status_line, |
10 | 10 | format_public_phase_pack_excerpt, |
11 | 11 | normalize_analysis_phase_bucket, |
| 12 | + rebuild_market_phase_summary_for_stock_code, |
12 | 13 | render_market_phase_summary, |
13 | 14 | ) |
14 | 15 |
|
@@ -125,6 +126,47 @@ def test_normalize_analysis_phase_bucket_maps_public_statistics_buckets() -> Non |
125 | 126 | assert normalize_analysis_phase_bucket("bad_phase") == "unknown" |
126 | 127 |
|
127 | 128 |
|
| 129 | +def test_rebuild_market_phase_summary_uses_auto_for_result_only_phases(monkeypatch) -> None: |
| 130 | + calls = [] |
| 131 | + |
| 132 | + class FakeContext: |
| 133 | + def to_dict(self) -> dict: |
| 134 | + return { |
| 135 | + **_phase_context(), |
| 136 | + "market": "jp", |
| 137 | + "phase": "non_trading", |
| 138 | + "analysis_intent": "auto", |
| 139 | + "warnings": [], |
| 140 | + } |
| 141 | + |
| 142 | + def fake_build_market_phase_context(**kwargs): |
| 143 | + calls.append(kwargs) |
| 144 | + return FakeContext() |
| 145 | + |
| 146 | + monkeypatch.setattr( |
| 147 | + "src.market_phase_summary.build_market_phase_context", |
| 148 | + fake_build_market_phase_context, |
| 149 | + ) |
| 150 | + |
| 151 | + summary = { |
| 152 | + **_phase_context(), |
| 153 | + "market": "cn", |
| 154 | + "phase": "non_trading", |
| 155 | + "analysis_intent": "non_trading", |
| 156 | + } |
| 157 | + |
| 158 | + rebuilt = rebuild_market_phase_summary_for_stock_code( |
| 159 | + "7203.T", |
| 160 | + {MARKET_PHASE_SUMMARY_KEY: summary}, |
| 161 | + ) |
| 162 | + |
| 163 | + assert rebuilt is not None |
| 164 | + assert rebuilt["phase"] == "non_trading" |
| 165 | + assert calls[0]["market"] == "jp" |
| 166 | + assert calls[0]["analysis_phase"] == "auto" |
| 167 | + assert calls[0]["analysis_intent"] == "auto" |
| 168 | + |
| 169 | + |
128 | 170 | def test_format_public_phase_pack_excerpt_limits_and_redacts_public_fields() -> None: |
129 | 171 | excerpt = format_public_phase_pack_excerpt( |
130 | 172 | { |
|
0 commit comments