Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #47

Merged
merged 11 commits into from
Jun 26, 2024
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
Loading