@@ -395,6 +395,65 @@ def test___ne__(self):
395
395
column_family2 = self ._makeOne ('column_family_id2' , None )
396
396
self .assertNotEqual (column_family1 , column_family2 )
397
397
398
+ def _create_test_helper (self , gc_rule = None ):
399
+ from gcloud .bigtable ._generated import (
400
+ bigtable_table_data_pb2 as data_pb2 )
401
+ from gcloud .bigtable ._generated import (
402
+ bigtable_table_service_messages_pb2 as messages_pb2 )
403
+ from gcloud .bigtable ._testing import _FakeStub
404
+
405
+ project_id = 'project-id'
406
+ zone = 'zone'
407
+ cluster_id = 'cluster-id'
408
+ table_id = 'table-id'
409
+ column_family_id = 'column-family-id'
410
+ timeout_seconds = 4
411
+ table_name = ('projects/' + project_id + '/zones/' + zone +
412
+ '/clusters/' + cluster_id + '/tables/' + table_id )
413
+
414
+ client = _Client (timeout_seconds = timeout_seconds )
415
+ table = _Table (table_name , client = client )
416
+ column_family = self ._makeOne (column_family_id , table , gc_rule = gc_rule )
417
+
418
+ # Create request_pb
419
+ if gc_rule is None :
420
+ column_family_pb = data_pb2 .ColumnFamily ()
421
+ else :
422
+ column_family_pb = data_pb2 .ColumnFamily (gc_rule = gc_rule .to_pb ())
423
+ request_pb = messages_pb2 .CreateColumnFamilyRequest (
424
+ name = table_name ,
425
+ column_family_id = column_family_id ,
426
+ column_family = column_family_pb ,
427
+ )
428
+
429
+ # Create response_pb
430
+ response_pb = data_pb2 .ColumnFamily ()
431
+
432
+ # Patch the stub used by the API method.
433
+ client ._table_stub = stub = _FakeStub (response_pb )
434
+
435
+ # Create expected_result.
436
+ expected_result = None # create() has no return value.
437
+
438
+ # Perform the method and check the result.
439
+ self .assertEqual (stub .results , (response_pb ,))
440
+ result = column_family .create ()
441
+ self .assertEqual (stub .results , ())
442
+ self .assertEqual (result , expected_result )
443
+ self .assertEqual (stub .method_calls , [(
444
+ 'CreateColumnFamily' ,
445
+ (request_pb , timeout_seconds ),
446
+
8196
{},
447
+ )])
448
+
449
+ def test_create (self ):
450
+ self ._create_test_helper (gc_rule = None )
451
+
452
+ def test_create_with_gc_rule (self ):
453
+ from gcloud .bigtable .column_family import MaxVersionsGCRule
454
+ gc_rule = MaxVersionsGCRule (1337 )
455
+ self ._create_test_helper (gc_rule = gc_rule )
456
+
398
457
def test_delete (self ):
399
458
from gcloud .bigtable ._generated import (
400
459
bigtable_table_service_messages_pb2 as messages_pb2 )
0 commit comments