1919import sys
2020
2121import grpc
22+ import math
2223
2324# special case python < 3.8
2425if sys .version_info .major == 3 and sys .version_info .minor < 8 :
3536from google .api_core import gapic_v1
3637from google .api_core import retry as retries
3738from google .api_core .gapic_v1 .client_info import METRICS_METADATA_KEY
39+ from google .api_core .timeout import ConstantTimeout
3840
3941from google .cloud .pubsub_v1 import publisher
4042from google .cloud .pubsub_v1 import types
@@ -652,6 +654,8 @@ def test_publish_new_batch_needed(creds):
652654 future = client .publish (topic , b"foo" , bar = b"baz" )
653655 assert future is mock .sentinel .future
654656
657+ call_args = batch_class .call_args
658+
655659 # Check the mocks.
656660 batch_class .assert_called_once_with (
657661 client = mock .ANY ,
@@ -660,8 +664,12 @@ def test_publish_new_batch_needed(creds):
660664 batch_done_callback = None ,
661665 commit_when_full = True ,
662666 commit_retry = gapic_v1 .method .DEFAULT ,
663- commit_timeout = gapic_v1 . method . DEFAULT ,
667+ commit_timeout = mock . ANY ,
664668 )
669+ commit_timeout_arg = call_args [1 ]["commit_timeout" ]
670+ assert isinstance (commit_timeout_arg , ConstantTimeout )
671+ assert math .isclose (commit_timeout_arg ._timeout , 60 ) is True
672+
665673 message_pb = gapic_types .PubsubMessage (data = b"foo" , attributes = {"bar" : "baz" })
666674 wrapper = PublishMessageWrapper (message = message_pb )
667675 batch1 .publish .assert_called_once_with (wrapper )
0 commit comments