@@ -85,7 +85,7 @@ def test_subscription():
8585
8686def test_ack ():
8787 policy = create_policy ()
88- policy ._consumer .active = True
88+ policy ._consumer .stopped . set ()
8989 with mock .patch .object (policy ._consumer , 'send_request' ) as send_request :
9090 policy .ack ('ack_id_string' , 20 )
9191 send_request .assert_called_once_with (types .StreamingPullRequest (
@@ -97,7 +97,7 @@ def test_ack():
9797
9898def test_ack_no_time ():
9999 policy = create_policy ()
100- policy ._consumer .active = True
100+ policy ._consumer .stopped . set ()
101101 with mock .patch .object (policy ._consumer , 'send_request' ) as send_request :
102102 policy .ack ('ack_id_string' )
103103 send_request .assert_called_once_with (types .StreamingPullRequest (
@@ -109,7 +109,7 @@ def test_ack_no_time():
109109def test_ack_paused ():
110110 policy = create_policy ()
111111 policy ._paused = True
112- policy ._consumer .active = False
112+ policy ._consumer .stopped . clear ()
113113 with mock .patch .object (policy , 'open' ) as open_ :
114114 policy .ack ('ack_id_string' )
115115 open_ .assert_called ()
@@ -198,20 +198,20 @@ def test_modify_ack_deadline():
198198
199199def test_maintain_leases_inactive_consumer ():
200200 policy = create_policy ()
201- policy ._consumer .active = False
201+ policy ._consumer .stopped . clear ()
202202 assert policy .maintain_leases () is None
203203
204204
205205def test_maintain_leases_ack_ids ():
206206 policy = create_policy ()
207- policy ._consumer .active = True
207+ policy ._consumer .stopped . set ()
208208 policy .lease ('my ack id' , 50 )
209209
210210 # Mock the sleep object.
211211 with mock .patch .object (time , 'sleep' , autospec = True ) as sleep :
212212 def trigger_inactive (seconds ):
213213 assert 0 < seconds < 10
214- policy ._consumer .active = False
214+ policy ._consumer .stopped . clear ()
215215 sleep .side_effect = trigger_inactive
216216
217217 # Also mock the consumer, which sends the request.
@@ -226,11 +226,11 @@ def trigger_inactive(seconds):
226226
227227def test_maintain_leases_no_ack_ids ():
228228 policy = create_policy ()
229- policy ._consumer .active = True
229+ policy ._consumer .stopped . set ()
230230 with mock .patch .object (time , 'sleep' , autospec = True ) as sleep :
231231 def trigger_inactive (seconds ):
232232 assert 0 < seconds < 10
233- policy ._consumer .active = False
233+ policy ._consumer .stopped . clear ()
234234 sleep .side_effect = trigger_inactive
235235 policy .maintain_leases ()
236236 sleep .assert_called ()
0 commit comments