mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 22:45:44 +00:00
fixed test_schema.py
This commit is contained in:
parent
6f62561793
commit
b587640fc5
@ -8,59 +8,11 @@ from planetmint.backend import Connection
|
|||||||
from planetmint.backend.tarantool.connection import TarantoolDB
|
from planetmint.backend.tarantool.connection import TarantoolDB
|
||||||
|
|
||||||
|
|
||||||
def test_init_database_is_graceful_if_db_exists():
|
# This function creates database, we have now only spaces so for now it is commented
|
||||||
conn = TarantoolDB('localhost', 3303)
|
# def test_init_database_is_graceful_if_db_exists():
|
||||||
conn.drop_database()
|
# conn = TarantoolDB('localhost', 3303)
|
||||||
conn.init_database()
|
# conn.drop_database()
|
||||||
|
# conn.init_database()
|
||||||
|
|
||||||
def test_create_tables():
|
|
||||||
from planetmint.backend import schema
|
|
||||||
|
|
||||||
conn = TarantoolDB('localhost', 3303)
|
|
||||||
# conn = Connection()
|
|
||||||
# dbname = Config().get()['database']['name']
|
|
||||||
|
|
||||||
# The db is set up by the fixtures so we need to remove it
|
|
||||||
conn.drop_database()
|
|
||||||
conn.init_database()
|
|
||||||
|
|
||||||
# TOTO verify spaces
|
|
||||||
# collection_names = conn.conn[dbname].list_collection_names()
|
|
||||||
# assert set(collection_names) == {
|
|
||||||
# 'transactions', 'assets', 'metadata', 'blocks', 'utxos', 'validators', 'elections',
|
|
||||||
# 'pre_commit', 'abci_chains',
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# indexes = conn.conn[dbname]['assets'].index_information().keys()
|
|
||||||
# assert set(indexes) == {'_id_', 'asset_id', 'text'}
|
|
||||||
#
|
|
||||||
# index_info = conn.conn[dbname]['transactions'].index_information()
|
|
||||||
# indexes = index_info.keys()
|
|
||||||
# assert set(indexes) == {
|
|
||||||
# '_id_', 'transaction_id', 'asset_id', 'outputs', 'inputs'}
|
|
||||||
# assert index_info['transaction_id']['unique']
|
|
||||||
#
|
|
||||||
# index_info = conn.conn[dbname]['blocks'].index_information()
|
|
||||||
# indexes = index_info.keys()
|
|
||||||
# assert set(indexes) == {'_id_', 'height'}
|
|
||||||
# assert index_info['height']['unique']
|
|
||||||
#
|
|
||||||
# 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)]
|
|
||||||
#
|
|
||||||
# indexes = conn.conn[dbname]['elections'].index_information()
|
|
||||||
# assert set(indexes.keys()) == {'_id_', 'election_id_height'}
|
|
||||||
# assert indexes['election_id_height']['unique']
|
|
||||||
#
|
|
||||||
# indexes = conn.conn[dbname]['pre_commit'].index_information()
|
|
||||||
# assert set(indexes.keys()) == {'_id_', 'height'}
|
|
||||||
# assert indexes['height']['unique']
|
|
||||||
|
|
||||||
def _check_spaces_by_list(conn, space_names):
|
def _check_spaces_by_list(conn, space_names):
|
||||||
_exists = []
|
_exists = []
|
||||||
@ -73,11 +25,18 @@ def _check_spaces_by_list(conn, space_names):
|
|||||||
return _exists
|
return _exists
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_tables():
|
||||||
|
conn = TarantoolDB('localhost', 3303)
|
||||||
|
# The db is set up by the fixtures so we need to remove it
|
||||||
|
conn.drop_database()
|
||||||
|
conn.init_database()
|
||||||
|
|
||||||
|
# TODO verify spaces
|
||||||
|
assert conn.SPACE_NAMES == _check_spaces_by_list(conn=conn, space_names=conn.SPACE_NAMES)
|
||||||
|
|
||||||
|
|
||||||
def test_drop(): # remove dummy_db as argument
|
def test_drop(): # remove dummy_db as argument
|
||||||
conn = TarantoolDB('localhost', 3303)
|
conn = TarantoolDB('localhost', 3303)
|
||||||
conn.drop_database()
|
conn.drop_database()
|
||||||
actual_spaces = _check_spaces_by_list(conn=conn, space_names=conn.SPACE_NAMES)
|
actual_spaces = _check_spaces_by_list(conn=conn, space_names=conn.SPACE_NAMES)
|
||||||
assert [] == actual_spaces
|
assert [] == actual_spaces
|
||||||
# conn.init_database()
|
|
||||||
# actual_spaces1 = _check_spaces_by_list(conn=conn, space_names=conn.SPACE_NAMES)
|
|
||||||
# assert conn.SPACE_NAMES == actual_spaces1
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user