@@ -210,11 +210,9 @@ def _verify_resource_properties(self, dataset, resource):
210
210
self .assertEqual (dataset .access_entries , [])
211
211
212
212
def test_ctor_defaults (self ):
213
- client = _Client (self .PROJECT )
214
- dataset = self ._make_one (self .DS_ID , client )
213
+ dataset = self ._make_one (self .DS_ID , project = self .PROJECT )
215
214
self .assertEqual (dataset .dataset_id , self .DS_ID )
216
- self .assertIs (dataset ._client , client )
217
- self .assertEqual (dataset .project , client .project )
215
+ self .assertEqual (dataset .project , self .PROJECT )
218
216
self .assertEqual (
219
217
dataset .path ,
220
218
'/projects/%s/datasets/%s' % (self .PROJECT , self .DS_ID ))
@@ -238,12 +236,10 @@ def test_ctor_explicit(self):
238
236
bharney = AccessEntry (
'OWNER' ,
'userByEmail' ,
'[email protected] ' )
239
237
entries = [phred , bharney ]
240
238
OTHER_PROJECT = 'foo-bar-123'
241
- client = _Client (self .PROJECT )
242
- dataset = self ._make_one (self .DS_ID , client ,
239
+ dataset = self ._make_one (self .DS_ID ,
243
240
access_entries = entries ,
244
241
project = OTHER_PROJECT )
245
242
self .assertEqual (dataset .dataset_id , self .DS_ID )
246
- self .assertIs (dataset ._client , client )
247
243
self .assertEqual (dataset .project , OTHER_PROJECT )
248
244
self .assertEqual (
249
245
dataset .path ,
@@ -262,89 +258,76 @@ def test_ctor_explicit(self):
262
258
self .assertIsNone (dataset .location )
263
259
264
260
def test_access_entries_setter_non_list (self ):
265
- client = _Client (self .PROJECT )
266
- dataset = self ._make_one (self .DS_ID , client )
261
+ dataset = self ._make_one (self .DS_ID )
267
262
with self .assertRaises (TypeError ):
268
263
dataset .access_entries = object ()
269
264
270
265
def test_access_entries_setter_invalid_field (self ):
271
266
from google .cloud .bigquery .dataset import AccessEntry
272
267
273
- client = _Client (self .PROJECT )
274
- dataset = self ._make_one (self .DS_ID , client )
268
+ dataset = self ._make_one (self .DS_ID )
275
269
phred = AccessEntry (
'OWNER' ,
'userByEmail' ,
'[email protected] ' )
276
270
with self .assertRaises (ValueError ):
277
271
dataset .access_entries = [phred , object ()]
278
272
279
273
def test_access_entries_setter (self ):
280
274
from google .cloud .bigquery .dataset import AccessEntry
281
275
282
- client = _Client (self .PROJECT )
283
- dataset = self ._make_one (self .DS_ID , client )
276
+ dataset = self ._make_one (self .DS_ID )
284
277
phred = AccessEntry (
'OWNER' ,
'userByEmail' ,
'[email protected] ' )
285
278
bharney = AccessEntry (
'OWNER' ,
'userByEmail' ,
'[email protected] ' )
286
279
dataset .access_entries = [phred , bharney ]
287
280
self .assertEqual (dataset .access_entries , [phred , bharney ])
288
281
289
282
def test_default_table_expiration_ms_setter_bad_value (self ):
290
- client = _Client (self .PROJECT )
291
- dataset = self ._make_one (self .DS_ID , client )
283
+ dataset = self ._make_one (self .DS_ID )
292
284
with self .assertRaises (ValueError ):
293
285
dataset .default_table_expiration_ms = 'bogus'
294
286
295
287
def test_default_table_expiration_ms_setter (self ):
296
- client = _Client (self .PROJECT )
297
- dataset = self ._make_one (self .DS_ID , client )
288
+ dataset = self ._make_one (self .DS_ID )
298
289
dataset .default_table_expiration_ms = 12345
299
290
self .assertEqual (dataset .default_table_expiration_ms , 12345 )
300
291
301
292
def test_description_setter_bad_value (self ):
302
- client = _Client (self .PROJECT )
303
- dataset = self ._make_one (self .DS_ID , client )
293
+ dataset = self ._make_one (self .DS_ID )
304
294
with self .assertRaises (ValueError ):
305
295
dataset .description = 12345
306
296
307
297
def test_description_setter (self ):
308
- client = _Client (self .PROJECT )
309
- dataset = self ._make_one (self .DS_ID , client )
298
+ dataset = self ._make_one (self .DS_ID )
310
299
dataset .description = 'DESCRIPTION'
311
300
self .assertEqual (dataset .description , 'DESCRIPTION' )
312
301
313
302
def test_friendly_name_setter_bad_value (self ):
314
- client = _Client (self .PROJECT )
315
- dataset = self ._make_one (self .DS_ID , client )
303
+ dataset = self ._make_one (self .DS_ID )
316
304
with self .assertRaises (ValueError ):
317
305
dataset .friendly_name = 12345
318
306
319
307
def test_friendly_name_setter (self ):
320
- client = _Client (self .PROJECT )
321
- dataset = self ._make_one (self .DS_ID , client )
308
+ dataset = self ._make_one (self .DS_ID )
322
309
dataset .friendly_name = 'FRIENDLY'
323
310
self .assertEqual (dataset .friendly_name , 'FRIENDLY' )
324
311
325
312
def test_location_setter_bad_value (self ):
326
- client = _Client (self .PROJECT )
327
- dataset = self ._make_one (self .DS_ID , client )
313
+ dataset = self ._make_one (self .DS_ID )
328
314
with self .assertRaises (ValueError ):
329
315
dataset .location = 12345
330
316
331
317
def test_location_setter (self ):
332
- client = _Client (self .PROJECT )
333
- dataset = self ._make_one (self .DS_ID , client )
318
+ dataset = self ._make_one (self .DS_ID )
334
319
dataset .location = 'LOCATION'
335
320
self .assertEqual (dataset .location , 'LOCATION' )
336
321
337
322
def test_from_api_repr_missing_identity (self ):
338
323
self ._setUpConstants ()
339
- client = _Client (self .PROJECT )
340
324
RESOURCE = {}
341
325
klass = self ._get_target_class ()
342
326
with self .assertRaises (KeyError ):
343
- klass .from_api_repr (RESOURCE , client = client )
327
+ klass .from_api_repr (RESOURCE )
344
328
345
329
def test_from_api_repr_bare (self ):
346
330
self ._setUpConstants ()
347
- client = _Client (self .PROJECT )
348
331
RESOURCE = {
349
332
'id' : '%s:%s' % (self .PROJECT , self .DS_ID ),
350
333
'datasetReference' : {
@@ -353,24 +336,20 @@ def test_from_api_repr_bare(self):
353
336
}
354
337
}
355
338
klass = self ._get_target_class ()
356
- dataset = klass .from_api_repr (RESOURCE , client = client )
357
- self .assertIs (dataset ._client , client )
339
+ dataset = klass .from_api_repr (RESOURCE )
358
340
self ._verify_resource_properties (dataset , RESOURCE )
359
341
360
342
def test_from_api_repr_w_properties (self ):
361
- client = _Client (self .PROJECT )
362
343
RESOURCE = self ._makeResource ()
363
344
klass = self ._get_target_class ()
364
- dataset = klass .from_api_repr (RESOURCE , client = client )
365
- self .assertIs (dataset ._client , client )
345
+ dataset = klass .from_api_repr (RESOURCE )
366
346
self ._verify_resource_properties (dataset , RESOURCE )
367
347
368
348
def test__parse_access_entries_w_unknown_entity_type (self ):
369
349
ACCESS = [
370
350
{'role' : 'READER' , 'unknown' : 'UNKNOWN' },
371
351
]
372
- client = _Client (self .PROJECT )
373
- dataset = self ._make_one (self .DS_ID , client = client )
352
+ dataset = self ._make_one (self .DS_ID )
374
353
with self .assertRaises (ValueError ):
375
354
dataset ._parse_access_entries (ACCESS )
376
355
@@ -383,24 +362,16 @@ def test__parse_access_entries_w_extra_keys(self):
383
362
'userByEmail' : USER_EMAIL ,
384
363
},
385
364
]
386
- client = _Client (self .PROJECT )
387
- dataset = self ._make_one (self .DS_ID , client = client )
365
+ dataset = self ._make_one (self .DS_ID )
388
366
with self .assertRaises (ValueError ):
389
367
dataset ._parse_access_entries (ACCESS )
390
368
391
369
def test_table (self ):
392
370
from google .cloud .bigquery .table import TableReference
393
371
394
- client = _Client (project = self .PROJECT )
395
- dataset = self ._make_one (self .DS_ID , client = client )
372
+ dataset = self ._make_one (self .DS_ID , project = self .PROJECT )
396
373
table = dataset .table ('table_id' )
397
374
self .assertIsInstance (table , TableReference )
398
375
self .assertEqual (table .table_id , 'table_id' )
399
376
self .assertEqual (table .dataset_id , self .DS_ID )
400
377
self .assertEqual (table .project , self .PROJECT )
401
-
402
-
403
- class _Client (object ):
404
-
405
- def __init__ (self , project = 'project' ):
406
- self .project = project
0 commit comments