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

Cutover to duckdb for unit tests #154

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cumulus_library/studies/core/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ file_names = [
export_list = [
"core__count_patient",
"core__count_encounter_month",
"core__count_encounter_service_month",
"core__count_encounter_priority_month",
'core__count_encounter_enc_type_month',
"core__count_encounter_type",
"core__count_encounter_type_month",
"core__count_documentreference_month",
Expand Down
27 changes: 25 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,40 @@
from cumulus_library.cli import StudyBuilder
from cumulus_library.databases import create_db_backend

MOCK_DATA_DIR = f"{Path(__file__).parent}/test_data/duckdb_data"


def duckdb_args(args, tmp_path):
"""Convenience function for adding duckdb args to a CLI mock"""
if args[0] == "build":
return args + [
"--db-type",
"duckdb",
"--load-ndjson-dir",
f"{MOCK_DATA_DIR}",
"--database",
f"{tmp_path}/duck.db",
]
elif args[0] == "export":
return args + [
"--db-type",
"duckdb",
"--database",
f"{tmp_path}/duck.db",
f"{tmp_path}/counts",
]
return args + ["--db-type", "duckdb", "--database", f"{tmp_path}/duck.db"]


@pytest.fixture
def mock_db():
"""Provides a DuckDatabaseBackend for local testing"""
data_dir = f"{Path(__file__).parent}/test_data/duckdb_data"
with tempfile.TemporaryDirectory() as tmpdir:
db = create_db_backend(
{
"db_type": "duckdb",
"schema_name": f"{tmpdir}/duck.db",
"load_ndjson_dir": data_dir,
"load_ndjson_dir": MOCK_DATA_DIR,
}
)
yield db
Expand Down
Binary file modified tests/regression/reference/core__count_condition_month.parquet
Binary file not shown.
Binary file not shown.
Loading