From 41a65520d72f1438d20b6bcb7568f0ed9aa6f751 Mon Sep 17 00:00:00 2001 From: andrei Date: Thu, 5 May 2022 15:40:55 +0300 Subject: [PATCH] test_commands.py -> all tests are passing --- planetmint/backend/tarantool/connection.py | 4 +--- planetmint/commands/planetmint.py | 5 ++++- tests/commands/test_commands.py | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/planetmint/backend/tarantool/connection.py b/planetmint/backend/tarantool/connection.py index 58061c5..9ebf247 100644 --- a/planetmint/backend/tarantool/connection.py +++ b/planetmint/backend/tarantool/connection.py @@ -5,7 +5,7 @@ import logging import tarantool -from planetmint.common.exceptions import DatabaseDoesNotExist + from planetmint.config import Config from planetmint.common.exceptions import ConfigurationError @@ -57,8 +57,6 @@ class TarantoolDB: db_config = Config().get()["database"] cmd_resp = self.run_command(command=self.drop_path, config=db_config) self._reconnect() - # if "nil" in cmd_resp: - # raise DatabaseDoesNotExist def init_database(self): db_config = Config().get()["database"] diff --git a/planetmint/commands/planetmint.py b/planetmint/commands/planetmint.py index 04db25b..2fbad65 100644 --- a/planetmint/commands/planetmint.py +++ b/planetmint/commands/planetmint.py @@ -268,7 +268,10 @@ def run_drop(args): from planetmint.backend.connection import Connection from planetmint.backend import schema conn = Connection() - schema.drop_database(conn) + try: + schema.drop_database(conn) + except DatabaseDoesNotExist: + print("Drop was executed, but spaces doesn't exist.", file=sys.stderr) def run_recover(b): diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index b8b3165..b1e73ad 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -132,8 +132,9 @@ def test_drop_db_when_db_does_not_exist(mock_db_drop, capsys): run_drop(args) output_message = capsys.readouterr()[1] - assert output_message == "Cannot drop '{name}'. The database does not exist.\n".format( - name=Config().get()['database']['name']) + assert output_message == "Drop was executed, but spaces doesn't exist.\n" + # assert output_message == "Cannot drop '{name}'. The database does not exist.\n".format( + # name=Config().get()['database']['name']) @patch('planetmint.backend.schema.drop_database')