Skip to content

Commit da850c5

Browse files
committed
mock metrics export for unit tests
1 parent 7caecfc commit da850c5

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

packages/google-cloud-bigtable/tests/unit/data/_async/test_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ def set_event_loop():
9393
asyncio.set_event_loop(None)
9494

9595

96+
@pytest.fixture(autouse=True)
97+
def mock_metrics_batch_write():
98+
"""mock out the metrics batch write to avoid sending metrics to GCP during tests."""
99+
with mock.patch(
100+
"google.cloud.bigtable.data._metrics.handlers.gcp_exporter.BigtableMetricsExporter._batch_write"
101+
):
102+
yield
103+
104+
96105
@CrossSync.convert_class(
97106
sync_name="TestBigtableDataClient",
98107
add_mapping_for_name="TestBigtableDataClient",

packages/google-cloud-bigtable/tests/unit/data/_sync_autogen/test_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ def set_event_loop():
7373
asyncio.set_event_loop(None)
7474

7575

76+
@pytest.fixture(autouse=True)
77+
def mock_metrics_batch_write():
78+
"""mock out the metrics batch write to avoid sending metrics to GCP during tests."""
79+
with mock.patch(
80+
"google.cloud.bigtable.data._metrics.handlers.gcp_exporter.BigtableMetricsExporter._batch_write"
81+
):
82+
yield
83+
84+
7685
@CrossSync._Sync_Impl.add_mapping_decorator("TestBigtableDataClient")
7786
class TestBigtableDataClient:
7887
@staticmethod

0 commit comments

Comments
 (0)