| 158 | |
| 159 | |
| 160 | def test_flush_on_failure_keeps_buffer(tmp_path): |
| 161 | _reset(tmp_path) |
| 162 | telem.enable() |
| 163 | |
| 164 | rec = telem.TelemetryRecord(predicted_tier=1, outcome="http_error") |
| 165 | telem.buffer_record(rec) |
| 166 | |
| 167 | # Mock failed send |
| 168 | with mock.patch.object(telem, "_send_batch", return_value=False): |
| 169 | count = telem.flush() |
| 170 | |
| 171 | assert count == 0 |
| 172 | assert telem.status()["pending_records"] == 1 # still pending |
| 173 | assert telem.status()["total_sent"] == 0 |
| 174 | |
| 175 | |
| 176 | def test_disabled_telemetry_does_not_buffer(tmp_path): |