@@ -34,18 +34,33 @@ def test_publisher_api_wo_gax(self):
3434 from google .cloud .pubsub import client as MUT
3535 from google .cloud ._testing import _Monkey
3636 creds = _Credentials ()
37- client = self ._makeOne (project = self .PROJECT , credentials = creds )
38- conn = client .connection = object ()
3937
4038 with _Monkey (MUT , _USE_GAX = False ):
41- api = client .publisher_api
39+ client = self ._makeOne (project = self .PROJECT , credentials = creds )
40+
41+ conn = client .connection = object ()
42+ api = client .publisher_api
4243
4344 self .assertIsInstance (api , _PublisherAPI )
4445 self .assertIs (api ._connection , conn )
4546 # API instance is cached
4647 again = client .publisher_api
4748 self .assertIs (again , api )
4849
50+ def test_no_gax_ctor (self ):
51+ from google .cloud ._testing import _Monkey
52+ from google .cloud .pubsub .connection import _PublisherAPI
53+ from google .cloud .pubsub import client as MUT
54+
55+ creds = _Credentials ()
56+ with _Monkey (MUT , _USE_GAX = True ):
57+ client = self ._makeOne (project = self .PROJECT , credentials = creds ,
58+ use_gax = False )
59+
60+ self .assertFalse (client ._use_gax )
61+ api = client .publisher_api
62+ self .assertIsInstance (api , _PublisherAPI )
63+
4964 def test_publisher_api_w_gax (self ):
5065 from google .cloud .pubsub import client as MUT
5166 from google .cloud ._testing import _Monkey
@@ -84,11 +99,12 @@ def test_subscriber_api_wo_gax(self):
8499 from google .cloud .pubsub import client as MUT
85100 from google .cloud ._testing import _Monkey
86101 creds = _Credentials ()
87- client = self ._makeOne (project = self .PROJECT , credentials = creds )
88- conn = client .connection = object ()
89102
90103 with _Monkey (MUT , _USE_GAX = False ):
91- api = client .subscriber_api
104+ client = self ._makeOne (project = self .PROJECT , credentials = creds )
105+
106+ conn = client .connection = object ()
107+ api = client .subscriber_api
92108
93109 self .assertIsInstance (api , _SubscriberAPI )
94110 self .assertIs (api ._connection , conn )
0 commit comments