def test_tables(self): from gcloud.bigtable.table import Table table_name1 = 'table-name1' table_name2 = 'table-name2' cluster = _Cluster(list_tables_result=[ Table(table_name1, None), Table(table_name2, None), ]) connection = self._makeOne(autoconnect=False, cluster=cluster) result = connection.tables() self.assertEqual(result, [table_name1, table_name2])
def test_tables_with_prefix(self): from gcloud.bigtable.table import Table table_prefix = 'prefix' table_prefix_separator = '<>' unprefixed_table_name1 = 'table-name1' table_name1 = (table_prefix + table_prefix_separator + unprefixed_table_name1) table_name2 = 'table-name2' instance = _Instance(list_tables_result=[ Table(table_name1, None), Table(table_name2, None), ]) connection = self._makeOne( autoconnect=False, instance=instance, table_prefix=table_prefix, table_prefix_separator=table_prefix_separator) result = connection.tables() self.assertEqual(result, [unprefixed_table_name1])
def table(self, name, use_prefix=True): """Table factory. :type name: str :param name: The name of the table to be created. :type use_prefix: bool :param use_prefix: Whether to use the table prefix (if any). :rtype: `Table <gcloud.bigtable.happybase.table.Table>` :returns: Table instance owned by this connection. """ if use_prefix: name = self._table_name(name) return Table(name, self)