def test_create_secondary_indexes(): import bigchaindb from bigchaindb import backend from bigchaindb.backend import schema conn = backend.connect() dbname = bigchaindb.config['database']['name'] # The db is set up by the fixtures so we need to remove it conn.conn.drop_database(dbname) schema.create_database(conn, dbname) schema.create_tables(conn, dbname) schema.create_indexes(conn, dbname) indexes = conn.conn[dbname]['assets'].index_information().keys() assert set(indexes) == {'_id_', 'asset_id', 'text'} indexes = conn.conn[dbname]['transactions'].index_information().keys() assert set(indexes) == { '_id_', 'transaction_id', 'asset_id', 'outputs', 'inputs'} indexes = conn.conn[dbname]['blocks'].index_information().keys() assert set(indexes) == {'_id_', 'height'} index_info = conn.conn[dbname]['utxos'].index_information() assert set(index_info.keys()) == {'_id_', 'utxo'} assert index_info['utxo']['unique'] assert index_info['utxo']['key'] == [('transaction_id', 1), ('output_index', 1)]
def test_create_secondary_indexes(): import bigchaindb from bigchaindb import backend from bigchaindb.backend import schema conn = backend.connect() dbname = bigchaindb.config['database']['name'] # The db is set up by the fixtures so we need to remove it conn.conn.drop_database(dbname) schema.create_database(conn, dbname) schema.create_tables(conn, dbname) schema.create_indexes(conn, dbname) # Bigchain table indexes = conn.conn[dbname]['bigchain'].index_information().keys() assert sorted(indexes) == ['_id_', 'asset_id', 'block_timestamp', 'inputs', 'outputs', 'transaction_id'] # Backlog table indexes = conn.conn[dbname]['backlog'].index_information().keys() assert sorted(indexes) == ['_id_', 'assignee__transaction_timestamp', 'transaction_id'] # Votes table indexes = conn.conn[dbname]['votes'].index_information().keys() assert sorted(indexes) == ['_id_', 'block_and_voter']