From 235e63ea0e57aefd137bad1ba7cdd91eba019022 Mon Sep 17 00:00:00 2001 From: kfilippopolitis Date: Tue, 25 Jun 2024 15:12:59 +0300 Subject: [PATCH] Added tests for no db validation --- mipdb/commands.py | 1 - mipdb/sqlite.py | 5 ----- tests/test_commands.py | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mipdb/commands.py b/mipdb/commands.py index 9cf312b..e3c16d2 100644 --- a/mipdb/commands.py +++ b/mipdb/commands.py @@ -38,7 +38,6 @@ class NotRequiredIf(cl.Option): def __init__(self, *args, **kwargs): credentials = credentials_from_config() - print(credentials) option_to_env_var = { "--ip": credentials["DB_IP"], "--port": credentials["DB_PORT"], diff --git a/mipdb/sqlite.py b/mipdb/sqlite.py index 332c80b..f35f35e 100644 --- a/mipdb/sqlite.py +++ b/mipdb/sqlite.py @@ -97,11 +97,6 @@ def execute_fetchall(self, query: str, *args, **kwargs) -> List[dict]: conn.close() return result - @contextmanager - def begin(self) -> Engine: - with self._executor.begin() as conn: - yield conn - def insert_values_to_table(self, table: sql.Table, values: List[dict]) -> None: session = self.Session() try: diff --git a/tests/test_commands.py b/tests/test_commands.py index 1fe19c5..75ba08b 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -18,6 +18,7 @@ from mipdb import list_data_models from mipdb import list_datasets from mipdb import validate_dataset +from mipdb.commands import validate_folder from mipdb.exceptions import ExitCode from mipdb.sqlite import Dataset, DataModel from mipdb.sqlite_tables import DataModelTable @@ -330,6 +331,22 @@ def test_invalid_dataset_error_cases(data_model, dataset, exception_message): ) +def test_validate_no_db(): + runner = CliRunner() + + validation_result = runner.invoke( + validate_folder, + [ + ABSOLUTE_PATH_FAIL_DATA_FOLDER + ] + ) + assert ( + """An error occurred while validating the csv on column: 'var2' + index failure_case +0 0 l3""" in validation_result.stdout + ) + + @pytest.mark.database @pytest.mark.usefixtures("monetdb_container", "cleanup_db") def test_validate_dataset(sqlite_db):