@@ -162,6 +162,35 @@ 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 ():
165194 table_data_client = mock .Mock (spec = ["table_path" ])
166195 _veneer_data_client = mock .Mock ()
167196 client = mock .Mock (
@@ -178,17 +207,35 @@ def test_table_constructor_defaults():
178207
179208 table = _make_table (TABLE_ID , instance )
180209
181- assert table .table_id == TABLE_ID
182- assert table ._instance is instance
183- assert table .mutation_timeout is None
184- assert table ._app_profile_id is None
185- assert table ._table_impl == _veneer_data_client .get_table .return_value
210+ assert table .name == table_data_client .table_path .return_value
211+
212+
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+ )
222+ instance = mock .Mock (
223+ _client = client ,
224+ instance_id = INSTANCE_ID ,
225+ spec = ["_client" , "instance_id" ],
226+ )
227+
228+ table = _make_table (TABLE_ID , instance )
229+ table ._veneer_data_table
230+
186231 _veneer_data_client .get_table .assert_called_once_with (
187- INSTANCE_ID , TABLE_ID , app_profile_id = None
232+ INSTANCE_ID ,
233+ TABLE_ID ,
234+ app_profile_id = None ,
188235 )
189236
190237
191- def test_table_constructor_explicit ():
238+ def test_table_veneer_data_table_not_initialized_explicit ():
192239 table_data_client = mock .Mock (spec = ["table_path" ])
193240 _veneer_data_client = mock .Mock ()
194241 client = mock .Mock (
@@ -202,29 +249,23 @@ def test_table_constructor_explicit():
202249 instance_id = INSTANCE_ID ,
203250 spec = ["_client" , "instance_id" ],
204251 )
205- mutation_timeout = 123
206- app_profile_id = "profile-123"
207252
253+ app_profile_id = "profile-123"
208254 table = _make_table (
209255 TABLE_ID ,
210256 instance ,
211- mutation_timeout = mutation_timeout ,
212257 app_profile_id = app_profile_id ,
213258 )
259+ table ._veneer_data_table
214260
215- assert table .table_id == TABLE_ID
216- assert table ._instance is instance
217- assert table .mutation_timeout == mutation_timeout
218- assert table ._app_profile_id == app_profile_id
219- assert table ._table_impl == _veneer_data_client .get_table .return_value
220261 _veneer_data_client .get_table .assert_called_once_with (
221262 INSTANCE_ID ,
222263 TABLE_ID ,
223264 app_profile_id = app_profile_id ,
224265 )
225266
226267
227- def test_table_name ():
268+ def test_table_veneer_data_table_initialized ():
228269 table_data_client = mock .Mock (spec = ["table_path" ])
229270 _veneer_data_client = mock .Mock ()
230271 client = mock .Mock (
@@ -240,8 +281,9 @@ def test_table_name():
240281 )
241282
242283 table = _make_table (TABLE_ID , instance )
243-
244- assert table .name == table_data_client .table_path .return_value
284+ already = table ._table_impl = object ()
285+ assert table ._veneer_data_table is already
286+ _veneer_data_client .get_table .assert_not_called ()
245287
246288
247289def _table_row_methods_helper ():
0 commit comments