| 135 | |
| 136 | |
| 137 | def test_flush_moves_to_sent_log(tmp_path): |
| 138 | _reset(tmp_path) |
| 139 | telem.enable() |
| 140 | |
| 141 | # Buffer a record |
| 142 | rec = telem.TelemetryRecord(predicted_tier=0, outcome="success") |
| 143 | telem.buffer_record(rec) |
| 144 | assert telem.status()["pending_records"] == 1 |
| 145 | |
| 146 | # Mock successful send |
| 147 | with mock.patch.object(telem, "_send_batch", return_value=True): |
| 148 | count = telem.flush() |
| 149 | |
| 150 | assert count == 1 |
| 151 | assert telem.status()["pending_records"] == 0 |
| 152 | assert telem.status()["total_sent"] == 1 |
| 153 | |
| 154 | # Verify sent log |
| 155 | sent = telem.get_sent_records() |
| 156 | assert len(sent) == 1 |
| 157 | assert sent[0]["predicted_tier"] == 0 |
| 158 | |
| 159 | |
| 160 | def test_flush_on_failure_keeps_buffer(tmp_path): |