8000 Bump histogram test coverage to 100% · googleapis/python-pubsub@aed7784 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit aed7784

Browse files
committed
Bump histogram test coverage to 100%
1 parent dc2b233 commit aed7784

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

tests/unit/pubsub_v1/subscriber/test_histogram.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_contains():
3333

3434
def test_max():
3535
histo = histogram.Histogram()
36-
assert histo.max == 600
36+
assert histo.max == histogram.MAX_ACK_DEADLINE
3737
histo.add(120)
3838
assert histo.max == 120
3939
histo.add(150)
@@ -44,7 +44,7 @@ def test_max():
4444

4545
def test_min():
4646
histo = histogram.Histogram()
47-
assert histo.min == 10
47+
assert histo.min == histogram.MIN_ACK_DEADLINE
4848
histo.add(60)
4949
assert histo.min == 60
5050
histo.add(30)
@@ -63,20 +63,23 @@ def test_add():
6363

6464
def test_add_lower_limit():
6565
histo = histogram.Histogram()
66-
histo.add(5)
67-
assert 5 not in histo
68-
assert 10 in histo
66+
low_value = histogram.MIN_ACK_DEADLINE - 1
67+
histo.add(low_value)
68+
assert low_value not in histo
69+
assert histogram.MIN_ACK_DEADLINE in histo
6970

7071

7172
def test_add_upper_limit():
7273
histo = histogram.Histogram()
73-
histo.add(12000)
74-
assert 12000 not in histo
75-
assert 600 in histo
74+
high_value = histogram.MAX_ACK_DEADLINE + 1
75+
histo.add(high_value)
76+
assert high_value not in histo
77+
assert histogram.MAX_ACK_DEADLINE in histo
7678

7779

7880
def test_percentile():
7981
histo = histogram.Histogram()
82+
assert histo.percentile(42) == histogram.MIN_ACK_DEADLINE # default when empty
8083
[histo.add(i) for i in range(101, 201)]
8184
assert histo.percentile(100) == 200
8285
assert histo.percentile(101) == 200

0 commit comments

Comments
 (0)
0