@@ -143,6 +143,51 @@ def test_create_with_split_keys(self):
143143 initial_split_keys = ['s1' , 's2' ]
144144 self ._create_test_helper (initial_split_keys )
145145
146+ def test_rename (self ):
147+ from gcloud .bigtable ._generated import (
148+ bigtable_table_service_messages_pb2 as messages_pb2 )
149+ from gcloud .bigtable ._generated import empty_pb2
150+ from gcloud .bigtable ._testing import _FakeStub
151+
152+ project_id = 'project-id'
153+ zone = 'zone'
154+ cluster_id = 'cluster-id'
155+ table_id = 'table-id'
156+ new_table_id = 'new_table_id'
157+ timeout_seconds = 97
158+ self .assertNotEqual (new_table_id , table_id )
159+
160+ client = _Client (timeout_seconds = timeout_seconds )
161+ cluster_name = ('projects/' + project_id + '/zones/' + zone +
162+ '/clusters/' + cluster_id )
163+ cluster = _Cluster (cluster_name , client = client )
164+ table = self ._makeOne (table_id , cluster )
165+
166+ # Create request_pb
167+ table_name = cluster_name + '/tables/' + table_id
168+ request_pb = messages_pb2 .RenameTableRequest (
169+ name = table_name ,
170+ new_id = new_table_id ,
171+ )
172+
173+ # Create response_pb
174+ response_pb = empty_pb2 .Empty ()
175+
176+ # Patch the stub used by the API method.
177+ client ._table_stub = stub = _FakeStub (response_pb )
178+
179+ # Create expected_result.
180+ expected_result = None # rename() has no return value.
181+
182+ # Perform the method and check the result.
183+ result = table .rename (new_table_id )
184+ self .assertEqual (result , expected_result )
185+ self .assertEqual (stub .method_calls , [(
186+ 'RenameTable' ,
187+ (request_pb , timeout_seconds ),
188+ {},
189+ )])
190+
146191 def test_delete (self ):
147192 from gcloud .bigtable ._generated import (
148193 bigtable_table_service_messages_pb2 as messages_pb2 )
0 commit comments