Skip to content

Commit c68d768

Browse files
committed
Fixing unit tests broken by previous commit.
1 parent ab3ead9 commit c68d768

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

pubsub/tests/unit/pubsub_v1/subscriber/test_policy_thread.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,41 @@ def test_init_with_executor():
5050

5151

5252
def test_close():
53+
dispatch_thread = mock.Mock(spec=threading.Thread)
54+
leases_thread = mock.Mock(spec=threading.Thread)
55+
5356
policy = create_policy()
54-
policy._dispatch_thread = mock.Mock(spec=('join',))
57+
policy._dispatch_thread = dispatch_thread
58+
policy._leases_thread = leases_thread
5559
consumer = policy._consumer
5660
with mock.patch.object(consumer, 'stop_consuming') as stop_consuming:
5761
policy.close()
5862
stop_consuming.assert_called_once_with()
5963

60-
policy._dispatch_thread.join.assert_called_once_with()
64+
assert policy._dispatch_thread is None
65+
dispatch_thread.join.assert_called_once_with()
66+
assert policy._leases_thread is None
67+
leases_thread.join.assert_called_once_with()
6168

6269

6370
def test_close_with_future():
71+
dispatch_thread = mock.Mock(spec=threading.Thread)
72+
leases_thread = mock.Mock(spec=threading.Thread)
73+
6474
policy = create_policy()
65-
policy._dispatch_thread = mock.Mock(spec=('join',))
75+
policy._dispatch_thread = dispatch_thread
76+
policy._leases_thread = leases_thread
6677
policy._future = Future(policy=policy)
6778
consumer = policy._consumer
6879
with mock.patch.object(consumer, 'stop_consuming') as stop_consuming:
6980
future = policy.future
7081
policy.close()
7182
stop_consuming.assert_called_once_with()
7283

73-
policy._dispatch_thread.join.assert_called_once_with()
84+
assert policy._dispatch_thread is None
85+
dispatch_thread.join.assert_called_once_with()
86+
assert policy._leases_thread is None
87+
leases_thread.join.assert_called_once_with()
7488
assert policy.future != future
7589
assert future.result() is None
7690

0 commit comments

Comments
 (0)