@@ -36,39 +36,24 @@ def _call_fut(self, client):
3636
3737 return _make_data_stub (client )
3838
39- def test_without_emulator (self ):
40- from google .cloud ._testing import _Monkey
39+ @mock .patch ('google.cloud.bigtable.client.make_secure_stub' ,
40+ return_value = mock .sentinel .stub )
41+ def test_without_emulator (self , make_stub ):
4142 from google .cloud .bigtable import client as MUT
4243
4344 credentials = _make_credentials ()
4445 user_agent = 'you-sir-age-int'
4546 client = _Client (credentials , user_agent )
4647
47- fake_stub = object ()
48- make_secure_stub_args = []
49-
50- def mock_make_secure_stub (* args , ** kwargs ):
51- make_secure_stub_args .append (args )
52- make_secure_stub_args .append (kwargs )
53- return fake_stub
54-
55- with _Monkey (MUT , make_secure_stub = mock_make_secure_stub ):
56- result = self ._call_fut (client )
57-
58- extra_options = {'extra_options' : (
59- ('grpc.max_message_length' , 104857600 ),
60- ('grpc.max_receive_message_length' , 104857600 )
61- )}
62- self .assertIs (result , fake_stub )
63- self .assertEqual (make_secure_stub_args , [
64- (
65- client .credentials ,
66- client .user_agent ,
67- MUT .bigtable_pb2 .BigtableStub ,
68- MUT .DATA_API_HOST ,
69- ),
70- extra_options ,
71- ])
48+ result = self ._call_fut (client )
49+ self .assertIs (result , mock .sentinel .stub )
50+ make_stub .assert_called_once_with (
51+ client .credentials ,
52+ client .user_agent ,
53+ MUT .bigtable_pb2 .BigtableStub ,
54+ MUT .DATA_API_HOST ,
55+ extra_options = MUT ._GRPC_MAX_LENGTH_OPTIONS ,
56+ )
7257
7358 def test_with_emulator (self ):
7459 from google .cloud ._testing import _Monkey
@@ -103,33 +88,24 @@ def _call_fut(self, client):
10388
10489 return _make_instance_stub (client )
10590
106- def test_without_emulator (self ):
107- from google .cloud ._testing import _Monkey
91+ @mock .patch ('google.cloud.bigtable.client.make_secure_stub' ,
92+ return_value = mock .sentinel .stub )
93+ def test_without_emulator (self , make_stub ):
10894 from google .cloud .bigtable import client as MUT
10995
11096 credentials = _make_credentials ()
11197 user_agent = 'you-sir-age-int'
11298 client = _Client (credentials , user_agent )
11399
114- fake_stub = object ()
115- make_secure_stub_args = []
116-
117- def mock_make_secure_stub (* args ):
118- make_secure_stub_args .append (args )
119- return fake_stub
120-
121- with _Monkey (MUT , make_secure_stub = mock_make_secure_stub ):
122- result = self ._call_fut (client )
123-
124- self .assertIs (result , fake_stub )
125- self .assertEqual (make_secure_stub_args , [
126- (
127- client .credentials ,
128- client .user_agent ,
129- MUT .bigtable_instance_admin_pb2 .BigtableInstanceAdminStub ,
130- MUT .INSTANCE_ADMIN_HOST ,
131- ),
132- ])
100+ result = self ._call_fut (client )
101+ self .assertIs (result , mock .sentinel .stub )
102+ make_stub .assert_called_once_with (
103+ client .credentials ,
104+ client .user_agent ,
105+ MUT .bigtable_instance_admin_pb2 .BigtableInstanceAdminStub ,
106+ MUT .INSTANCE_ADMIN_HOST ,
107+ extra_options = MUT ._GRPC_EXTRA_OPTIONS ,
108+ )
133109
134110 def test_with_emulator (self ):
135111 from google .cloud ._testing import _Monkey
@@ -164,35 +140,25 @@ def _call_fut(self, client):
164140
165141 return _make_operations_stub (client )
166142
167- def test_without_emulator (self ):
143+ @mock .patch ('google.cloud.bigtable.client.make_secure_stub' ,
144+ return_value = mock .sentinel .stub )
145+ def test_without_emulator (self , make_stub ):
168146 from google .longrunning import operations_grpc
169-
170- from google .cloud ._testing import _Monkey
171147 from google .cloud .bigtable import client as MUT
172148
173149 credentials = _make_credentials ()
174150 user_agent = 'you-sir-age-int'
175151 client = _Client (credentials , user_agent )
176152
177- fake_stub = object ()
178- make_secure_stub_args = []
179-
180- def mock_make_secure_stub (* args ):
181- make_secure_stub_args .append (args )
182- return fake_stub
183-
184- with _Monkey (MUT , make_secure_stub = mock_make_secure_stub ):
185- result = self ._call_fut (client )
186-
187- self .assertIs (result , fake_stub )
188- self .assertEqual (make_secure_stub_args , [
189- (
190- client .credentials ,
191- client .user_agent ,
192- operations_grpc .OperationsStub ,
193- MUT .OPERATIONS_API_HOST ,
194- ),
195- ])
153+ result = self ._call_fut (client )
154+ self .assertIs (result , mock .sentinel .stub )
155+ make_stub .assert_called_once_with (
156+ client .credentials ,
157+ client .user_agent ,
158+ operations_grpc .OperationsStub ,
159+ MUT .OPERATIONS_API_HOST ,
160+ extra_options = MUT ._GRPC_EXTRA_OPTIONS ,
161+ )
196162
197163 def test_with_emulator (self ):
198164 from google .longrunning import operations_grpc
@@ -229,33 +195,24 @@ def _call_fut(self, client):
229195
230196 return _make_table_stub (client )
231197
232- def test_without_emulator (self ):
233- from google .cloud ._testing import _Monkey
198+ @mock .patch ('google.cloud.bigtable.client.make_secure_stub' ,
199+ return_value = mock .sentinel .stub )
200+ def test_without_emulator (self , make_stub ):
234201 from google .cloud .bigtable import client as MUT
235202
236203 credentials = _make_credentials ()
237204 user_agent = 'you-sir-age-int'
238205 client = _Client (credentials , user_agent )
239206
240- fake_stub = object ()
241- make_secure_stub_args = []
242-
243- def mock_make_secure_stub (* args ):
244- make_secure_stub_args .append (args )
245- return fake_stub
246-
247- with _Monkey (MUT , make_secure_stub = mock_make_secure_stub ):
248- result = self ._call_fut (client )
249-
250- self .assertIs (result , fake_stub )
251- self .assertEqual (make_secure_stub_args , [
252- (
253- client .credentials ,
254- client .user_agent ,
255- MUT .bigtable_table_admin_pb2 .BigtableTableAdminStub ,
256- MUT .TABLE_ADMIN_HOST ,
257- ),
258- ])
207+ result = self ._call_fut (client )
208+ self .assertIs (result , mock .sentinel .stub )
209+ make_stub .assert_called_once_with (
210+ client .credentials ,
211+ client .user_agent ,
212+ MUT .bigtable_table_admin_pb2 .BigtableTableAdminStub ,
213+ MUT .TABLE_ADMIN_HOST ,
214+ extra_options = MUT ._GRPC_EXTRA_OPTIONS ,
215+ )
259216
260217 def test_with_emulator (self ):
261218 from google .cloud ._testing import _Monkey
0 commit comments