Assert the CSV output matches expected diffs exactly. The CSV has columns like (event_time, data, chunk_start, time, diff). We consolidate, drop time, and combine remaining columns into strings. Diffs must be exactly +1 or -1.
(output_path: pathlib.Path, expected: set)
| 318 | |
| 319 | |
| 320 | def _assert_diffs_match(output_path: pathlib.Path, expected: set) -> None: |
| 321 | """Assert the CSV output matches expected diffs exactly. |
| 322 | |
| 323 | The CSV has columns like (event_time, data, chunk_start, time, diff). |
| 324 | We consolidate, drop time, and combine remaining columns into strings. |
| 325 | Diffs must be exactly +1 or -1. |
| 326 | """ |
| 327 | _assert_diffs_are_unit(output_path) |
| 328 | try: |
| 329 | df = consolidate(pd.read_csv(output_path)) |
| 330 | except pd.errors.EmptyDataError: |
| 331 | assert expected == set(), f"Expected {expected} but output was empty" |
| 332 | return |
| 333 | |
| 334 | actual = set(combine_columns(df)) |
| 335 | assert ( |
| 336 | actual == expected |
| 337 | ), f"Diffs mismatch:\n actual: {sorted(actual)}\n expected: {sorted(expected)}" |
| 338 | |
| 339 | |
| 340 | def _compute_chunk_assignments(events: dict) -> dict: |
no test coverage detected