Skip to content

Commit

Permalink
Added tests for no db validation
Browse files Browse the repository at this point in the history
  • Loading branch information
KFilippopolitis committed Jun 25, 2024
1 parent 1e19e3e commit 235e63e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion mipdb/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
5 changes: 0 additions & 5 deletions mipdb/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 235e63e

Please sign in to comment.