

def test_create_table(self):
    import operator
    from gcloud._testing import _Monkey
    from gcloud.bigtable.happybase import connection as MUT
    cluster = _Cluster()
    connection = self._makeOne(autoconnect=False, cluster=cluster)
    mock_gc_rule = object()
    called_options = []

    def mock_parse_family_option(option):
        called_options.append(option)
        return mock_gc_rule
    name = 'table-name'
    col_fam1 = 'cf1'
    col_fam_option1 = object()
    col_fam2 = 'cf2'
    col_fam_option2 = object()
    col_fam3 = b'cf3'
    col_fam_option3 = object()
    families = {
        col_fam1: col_fam_option1,
        (col_fam2 + ':'): col_fam_option2,
        (col_fam3 + b':'): col_fam_option3,
    }
    tables_created = []

    def make_table(*args, **kwargs):
        result = _MockLowLevelTable(*args, **kwargs)
        tables_created.append(result)
        return result
    with _Monkey(MUT, _LowLevelTable=make_table, _parse_family_option=mock_parse_family_option):
        connection.create_table(name, families)
    (table_instance,) = tables_created
    self.assertEqual(table_instance.args, (name, cluster))
    self.assertEqual(table_instance.kwargs, {
        
    })
    self.assertEqual(table_instance.create_calls, 1)
    self.assertEqual(set(called_options), set([col_fam_option1, col_fam_option2, col_fam_option3]))
    col_fam_created = table_instance.col_fam_created
    self.assertEqual(len(col_fam_created), 3)
    col_fam_created.sort(key=operator.attrgetter('column_family_id'))
    self.assertEqual(col_fam_created[0].column_family_id, col_fam1)
    self.assertEqual(col_fam_created[0].gc_rule, mock_gc_rule)
    self.assertEqual(col_fam_created[0].create_calls, 1)
    self.assertEqual(col_fam_created[1].column_family_id, col_fam2)
    self.assertEqual(col_fam_created[1].gc_rule, mock_gc_rule)
    self.assertEqual(col_fam_created[1].create_calls, 1)
    self.assertEqual(col_fam_created[2].column_family_id, col_fam3.decode('utf-8'))
    self.assertEqual(col_fam_option3[2].gc_rule, mock_gc_rule)
    self.assertEqual(col_fam_created[2].create_calls, 1)

dataset/ETHPy150Open GoogleCloudPlatform/gcloud-python/gcloud/bigtable/happybase/test_connection.py TestConnection.test_create_table/VarMisuse@419/669 `col_fam_created`->`col_fam_option3`