|
14 | 14 | from __future__ import annotations |
15 | 15 |
|
16 | 16 | import json |
| 17 | +from collections.abc import Callable |
17 | 18 | from unittest.mock import MagicMock, patch |
18 | 19 |
|
19 | 20 | import pandas as pd |
@@ -269,3 +270,34 @@ def test_missing_sections_yield_defaults(self) -> None: |
269 | 270 | def test_none_transport_response_maps_to_failure(self) -> None: |
270 | 271 | assert dry_publish_response_to_domain(None).success is False |
271 | 272 | assert publish_response_to_domain(None).success is False |
| 273 | + |
| 274 | + |
| 275 | +class TestBatchNumberIsHiddenFromOutput: |
| 276 | + @pytest.mark.parametrize( |
| 277 | + ("envelope", "over_wire"), |
| 278 | + [ |
| 279 | + (FAILED_DRY_PUBLISH_ENVELOPE, _dry_publish_over_wire), |
| 280 | + (PASSED_DRY_PUBLISH_ENVELOPE, _dry_publish_over_wire), |
| 281 | + (PUBLISH_ENVELOPE, _publish_over_wire), |
| 282 | + ], |
| 283 | + ids=["dry_publish_failure", "dry_publish_success", "publish"], |
| 284 | + ) |
| 285 | + def test_batch_number_absent_from_printed_output( |
| 286 | + self, envelope: dict, over_wire: Callable[[dict], DryPublishResult | PublishResult] |
| 287 | + ) -> None: |
| 288 | + result = over_wire(envelope) |
| 289 | + |
| 290 | + assert "dataset_batch_number" not in repr(result) |
| 291 | + assert "dataset_batch_number" not in repr(result.metadata) |
| 292 | + |
| 293 | + def test_publish_batch_number_is_still_readable(self) -> None: |
| 294 | + result = _publish_over_wire(PUBLISH_ENVELOPE) |
| 295 | + |
| 296 | + assert result.metadata.dataset_batch_number == 1 |
| 297 | + assert result.dataset_batch_number == 1 |
| 298 | + |
| 299 | + def test_other_metadata_still_printed(self) -> None: |
| 300 | + printed = repr(_publish_over_wire(PUBLISH_ENVELOPE).metadata) |
| 301 | + |
| 302 | + for field_name in ("dataset_name", "dataset_version", "column_count", "dataset_uuid"): |
| 303 | + assert field_name in printed |
0 commit comments