@@ -311,6 +311,37 @@ def test_tables_with_prefix(self):
311311 result = connection .tables ()
312312 self .assertEqual (result , [unprefixed_table_name1 ])
313313
314+ def test_delete_table (self ):
315+ from gcloud ._testing import _Monkey
316+ from gcloud .bigtable .happybase import connection as MUT
317+
318+ cluster = _Cluster () # Avoid implicit environ check.
319+ connection = self ._makeOne (autoconnect = False , cluster = cluster )
320+
321+ tables_created = []
322+
323+ def make_table (* args , ** kwargs ):
324+ result = _MockLowLevelTable (* args , ** kwargs )
325+ tables_created .append (result )
326+ return result
327+
328+ name = 'table-name'
329+ with _Monkey (MUT , _LowLevelTable = make_table ):
330+ connection .delete_table (name )
331+
332+ # Just one table would have been created.
333+ table_instance , = tables_created
334+ self .assertEqual (table_instance .args , (name , cluster ))
335+ self .assertEqual (table_instance .kwargs , {})
336+ self .assertEqual (table_instance .delete_calls , 1 )
337+
338+ def test_delete_table_disable (self ):
339+ cluster = _Cluster () # Avoid implicit environ check.
340+ connection = self ._makeOne (autoconnect = False , cluster = cluster )
341+ name = 'table-name'
342+ with self .assertRaises (ValueError ):
343+ connection .delete_table (name , disable = True )
344+
314345 def test_enable_table (self ):
315346 cluster = _Cluster () # Avoid implicit environ check.
316347 connection = self ._makeOne (autoconnect = False , cluster = cluster )
@@ -385,3 +416,14 @@ def copy(self):
385416
386417 def list_tables (self ):
387418 return self .list_tables_result
419+
420+
421+ class _MockLowLevelTable (object ):
422+
423+ def __init__ (self , * args , ** kwargs ):
424+ self .args = args
425+ self .kwargs = kwargs
426+ self .delete_calls = 0
427+
428+ def delete (self ):
429+ self .delete_calls += 1
0 commit comments