@@ -162,110 +162,62 @@ def _make_table(*args, **kwargs):
162162
163163
164164def test_table_constructor_defaults ():
165- instance = mock .Mock (spec = [])
166-
167- table = _make_table (TABLE_ID , instance )
168-
169- assert table .table_id == TABLE_ID
170- assert table ._instance is instance
171- assert table .mutation_timeout is None
172- assert table ._app_profile_id is None
173-
174-
175- def test_table_constructor_explicit ():
176- instance = mock .Mock (spec = [])
177- mutation_timeout = 123
178- app_profile_id = "profile-123"
179-
180- table = _make_table (
181- TABLE_ID ,
182- instance ,
183- mutation_timeout = mutation_timeout ,
184- app_profile_id = app_profile_id ,
185- )
186-
187- assert table .table_id == TABLE_ID
188- assert table ._instance is instance
189- assert table .mutation_timeout == mutation_timeout
190- assert table ._app_profile_id == app_profile_id
191-
192-
193- def test_table_name ():
194- table_data_client = mock .Mock (spec = ["table_path" ])
195- _veneer_data_client = mock .Mock ()
196- client = mock .Mock (
197- project = PROJECT_ID ,
198- table_data_client = table_data_client ,
199- _veneer_data_client = _veneer_data_client ,
200- spec = ["project" , "table_data_client" , "_veneer_data_client" ],
201- )
202- instance = mock .Mock (
203- _client = client ,
204- instance_id = INSTANCE_ID ,
205- spec = ["_client" , "instance_id" ],
206- )
207-
208- table = _make_table (TABLE_ID , instance )
209-
210- assert table .name == table_data_client .table_path .return_value
211-
165+ from google .cloud .bigtable .client import Client
212166
213- def test_table_veneer_data_table_not_initialized_defaults ():
214- table_data_client = mock .Mock (spec = ["table_path" ])
215- _veneer_data_client = mock .Mock ()
216- client = mock .Mock (
217- project = PROJECT_ID ,
218- table_data_client = table_data_client ,
219- _veneer_data_client = _veneer_data_client ,
220- spec = ["project" , "table_data_client" , "_veneer_data_client" ],
221- )
167+ client = mock .create_autospec (Client )
222168 instance = mock .Mock (
223169 _client = client ,
224170 instance_id = INSTANCE_ID ,
225171 spec = ["_client" , "instance_id" ],
226172 )
227173
228174 table = _make_table (TABLE_ID , instance )
229- table ._veneer_data_table
230175
231- _veneer_data_client .get_table .assert_called_once_with (
176+ assert table .table_id == TABLE_ID
177+ assert table ._instance is instance
178+ assert table .mutation_timeout is None
179+ assert table ._app_profile_id is None
180+ assert table ._table_impl is client ._veneer_data_client .get_table .return_value
181+ client ._veneer_data_client .get_table .assert_called_once_with (
232182 INSTANCE_ID ,
233183 TABLE_ID ,
234184 app_profile_id = None ,
235185 )
236186
237187
238- def test_table_veneer_data_table_not_initialized_explicit ():
239- table_data_client = mock .Mock (spec = ["table_path" ])
240- _veneer_data_client = mock .Mock ()
241- client = mock .Mock (
242- project = PROJECT_ID ,
243- table_data_client = table_data_client ,
244- _veneer_data_client = _veneer_data_client ,
245- spec = ["project" , "table_data_client" , "_veneer_data_client" ],
246- )
188+ def test_table_constructor_explicit ():
189+ from google .cloud .bigtable .client import Client
190+
191+ client = mock .create_autospec (Client )
247192 instance = mock .Mock (
248193 _client = client ,
249194 instance_id = INSTANCE_ID ,
250195 spec = ["_client" , "instance_id" ],
251196 )
252197
198+ mutation_timeout = 123
253199 app_profile_id = "profile-123"
200+
254201 table = _make_table (
255202 TABLE_ID ,
256203 instance ,
204+ mutation_timeout = mutation_timeout ,
257205 app_profile_id = app_profile_id ,
258206 )
259- table ._veneer_data_table
260207
261- _veneer_data_client .get_table .assert_called_once_with (
208+ assert table .table_id == TABLE_ID
209+ assert table ._instance is instance
210+ assert table .mutation_timeout == mutation_timeout
211+ assert table ._app_profile_id == app_profile_id
212+ assert table ._table_impl is client ._veneer_data_client .get_table .return_value
213+ client ._veneer_data_client .get_table .assert_called_once_with (
262214 INSTANCE_ID ,
263215 TABLE_ID ,
264216 app_profile_id = app_profile_id ,
265217 )
266218
267219
268- def test_table_veneer_data_table_initialized ():
220+ def test_table_name ():
269221 table_data_client = mock .Mock (spec = ["table_path" ])
270222 _veneer_data_client = mock .Mock ()
271223 client = mock .Mock (
@@ -281,9 +233,8 @@ def test_table_veneer_data_table_initialized():
281233 )
282234
283235 table = _make_table (TABLE_ID , instance )
284- already = table ._table_impl = object ()
285- assert table ._veneer_data_table is already
286- _veneer_data_client .get_table .assert_not_called ()
236+
237+ assert table .name == table_data_client .table_path .return_value
287238
288239
289240def _table_row_methods_helper ():
@@ -417,8 +368,9 @@ def test_table___ne__same_value():
417368
418369
419370def test_table___ne__ ():
420- table1 = _make_table ("table_id1" , None )
421- table2 = _make_table ("table_id2" , None )
371+ mock_instance = mock .Mock ()
372+ table1 = _make_table ("table_id1" , mock_instance )
373+ table2 = _make_table ("table_id2" , mock_instance )
422374 assert table1 != table2
423375
424376
@@ -1340,7 +1292,7 @@ def test_table_drop_by_prefix_w_timeout():
13401292def test_table_mutations_batcher_factory ():
13411293 flush_count = 100
13421294 max_row_bytes = 1000
1343- table = _make_table (TABLE_ID , None )
1295+ table = _make_table (TABLE_ID , mock . Mock () )
13441296 mutation_batcher = table .mutations_batcher (
13451297 flush_count = flush_count , max_row_bytes = max_row_bytes
13461298 )
0 commit comments