fixed backend problem with command make tests

This commit is contained in:
andrei 2022-04-25 13:39:05 +03:00
parent 2e749f64ef
commit 0e50b2e869
3 changed files with 7 additions and 9 deletions

View File

@ -19,7 +19,7 @@ logger = logging.getLogger(__name__)
def Connection(host: str = None, port: int = None, login: str = None, password: str = None, backend: str = None,
**kwargs):
backend = backend
if not backend and kwargs and kwargs["backend"]:
if not backend and kwargs and kwargs.get("backend"):
backend = kwargs["backend"]
if backend and backend != Config().get()["database"]["backend"]:
@ -37,7 +37,7 @@ def Connection(host: str = None, port: int = None, login: str = None, password:
Class = getattr(import_module(modulepath), class_name)
print("LOGIN " + str(login))
print("PASSWORD " + str(password))
return Class(host=host, port=port, user=login, password=password)
return Class(host=host, port=port, user=login, password=password, kwargs=kwargs)
elif backend == "localmongodb":
modulepath, _, class_name = BACKENDS[backend].rpartition('.')
Class = getattr(import_module(modulepath), class_name)

View File

@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
class TarantoolDB:
def __init__(self, host: str = "localhost", port: int = 3303, user: str = None, password: str = None,
reset_database: bool = False):
reset_database: bool = False, **kwargs):
try:
self.host = host
self.port = port
@ -22,12 +22,11 @@ class TarantoolDB:
print(f"host : {host}")
print(f"port : {port}")
# self.db_connect = tarantool.connect(host=host, port=port, user=user, password=password)
#TODO : raise configuraiton error if the connection cannot be established
# TODO : raise configuraiton error if the connection cannot be established
self.db_connect = tarantool.connect(host=self.host, port=self.port)
print( f"connection : {self.db_connect}")
self.init_path = Config().get()["database"]["init_config"]["absolute_path"]
self.drop_path = Config().get()["database"]["drop_config"]["absolute_path"]
if reset_database:
if reset_database or kwargs.get("kwargs").get("reset_database"):
self.drop_database()
self.init_database()
self._reconnect()
@ -36,8 +35,7 @@ class TarantoolDB:
"transactions", "inputs", "outputs", "keys"]
except:
logger.info('Exception in _connect(): {}')
raise ConfigurationError
raise ConfigurationError
def _reconnect(self):
self.db_connect = tarantool.connect(host=self.host, port=self.port)

View File

@ -77,7 +77,7 @@ class Planetmint(object):
else:
self.validation = BaseValidationRules
# planetmint.backend.tarantool.connection_tarantool.connect(**Config().get()['database'])
self.connection = connection if connection is not None else planetmint.backend.Connection()
self.connection = connection if connection is not None else planetmint.backend.Connection(reset_database=True)
print(f"PLANETMINT self.connection {self.connection} !!!!")
def post_transaction(self, transaction, mode):