2424 ScopeMetrics ,
2525 Metric ,
2626 Sum ,
27- Histogram ,
2827 AggregationTemporality ,
2928)
3029from google .cloud .monitoring_v3 import (
4645
4746
4847class TestGoogleCloudMetricsHandler :
49-
5048 def _make_one (self , * args , ** kwargs ):
5149 return GoogleCloudMetricsHandler (* args , ** kwargs )
5250
@@ -62,7 +60,7 @@ def test_ctor_defaults(self):
6260 handler = self ._make_one (
6361 expected_exporter ,
6462 instance_id = expected_instance ,
65- table_id = expected_table
63+ table_id = expected_table ,
6664 )
6765 assert isinstance (handler .meter_provider , MeterProvider )
6866 assert isinstance (handler .otel , _OpenTelemetryInstruments )
@@ -80,7 +78,6 @@ def test_ctor_explicit(self):
8078 expected_version = "my_version"
8179 expected_uid = "my_uid"
8280 expected_app_profile = "my_profile"
83- expected_instruments = object ()
8481 expected_exporter = BigtableMetricsExporter ("project" )
8582 handler = self ._make_one (
8683 expected_exporter ,
@@ -99,8 +96,6 @@ def test_ctor_explicit(self):
9996 )
10097 assert handler .shared_labels ["client_uid" ] == expected_uid
10198
102-
103-
10499 @mock .patch (
105100 "google.cloud.bigtable.data._metrics.handlers.gcp_exporter.PeriodicExportingMetricReader"
106101 )
@@ -188,13 +183,20 @@ def test__to_point_w_number(self, value, expected_field):
188183 expected_start_time_nanos = 100
189184 expected_end_time_nanos = 200
190185 dp = NumberDataPoint (
191- attributes = {}, start_time_unix_nano = expected_start_time_nanos , time_unix_nano = expected_end_time_nanos , value = value
186+ attributes = {},
187+ start_time_unix_nano = expected_start_time_nanos ,
188+ time_unix_nano = expected_end_time_nanos ,
189+ value = value ,
192190 )
193191 point = instance ._to_point (dp )
194192 assert isinstance (point , Point )
195193 assert getattr (point .value , expected_field ) == value
196- assert (point .interval .start_time .second * 10 ** 9 ) + point .interval .start_time .nanosecond == expected_start_time_nanos
197- assert (point .interval .end_time .second * 10 ** 9 ) + point .interval .end_time .nanosecond == expected_end_time_nanos
194+ assert (
195+ point .interval .start_time .second * 10 ** 9
196+ ) + point .interval .start_time .nanosecond == expected_start_time_nanos
197+ assert (
198+ point .interval .end_time .second * 10 ** 9
199+ ) + point .interval .end_time .nanosecond == expected_end_time_nanos
198200
199201 def test__to_point_w_histogram (self ):
200202 """Test that HistogramDataPoint is converted to a Point correctly."""
@@ -223,9 +225,16 @@ def test__to_point_w_histogram(self):
223225 assert dist .count == expected_count
224226 assert dist .mean == expected_sum / expected_count
225227 assert list (dist .bucket_counts ) == expected_bucket_counts
226- assert list (dist .bucket_options .explicit_buckets .bounds ) == expected_explicit_bounds
227- assert (point .interval .start_time .second * 10 ** 9 ) + point .interval .start_time .nanosecond == expected_start_time_nanos
228- assert (point .interval .end_time .second * 10 ** 9 ) + point .interval .end_time .nanosecond == expected_end_time_nanos
228+ assert (
229+ list (dist .bucket_options .explicit_buckets .bounds )
230+ == expected_explicit_bounds
231+ )
232+ assert (
233+ point .interval .start_time .second * 10 ** 9
234+ ) + point .interval .start_time .nanosecond == expected_start_time_nanos
235+ assert (
236+ point .interval .end_time .second * 10 ** 9
237+ ) + point .interval .end_time .nanosecond == expected_end_time_nanos
229238
230239 def test__to_point_w_histogram_zero_count (self ):
231240 """Test that HistogramDataPoint with zero count is converted to a Point correctly."""
@@ -329,7 +338,9 @@ def test_export(self):
329338 is_monotonic = False ,
330339 ),
331340 )
332- scope_metric = ScopeMetrics (scope = mock .Mock (), metrics = [metric ], schema_url = None )
341+ scope_metric = ScopeMetrics (
342+ scope = mock .Mock (), metrics = [metric ], schema_url = None
343+ )
333344 resource_metric = ResourceMetrics (
334345 resource = mock .Mock (), scope_metrics = [scope_metric ], schema_url = None
335346 )
@@ -372,7 +383,9 @@ def test_export_no_attributes(self):
372383 is_monotonic = False ,
373384 ),
374385 )
375- scope_metric = ScopeMetrics (scope = mock .Mock (), metrics = [metric ], schema_url = None )
386+ scope_metric = ScopeMetrics (
387+ scope = mock .Mock (), metrics = [metric ], schema_url = None
388+ )
376389 resource_metric = ResourceMetrics (
377390 resource = mock .Mock (), scope_metrics = [scope_metric ], schema_url = None
378391 )
@@ -412,7 +425,9 @@ def test_exception_in_export(self):
412425 is_monotonic = False ,
413426 ),
414427 )
415- scope_metric = ScopeMetrics (scope = mock .Mock (), metrics = [metric ], schema_url = None )
428+ scope_metric = ScopeMetrics (
429+ scope = mock .Mock (), metrics = [metric ], schema_url = None
430+ )
416431 resource_metric = ResourceMetrics (
417432 resource = mock .Mock (), scope_metrics = [scope_metric ], schema_url = None
418433 )
0 commit comments