Skip to content

Commit

Permalink
Cutover to duckdb for unit tests (#154)
Browse files Browse the repository at this point in the history
* Cutover to duckdb for unit tests

* line breaks, export check

* Update test data for additional exports
  • Loading branch information
dogversioning authored Dec 8, 2023
1 parent 5b1c851 commit 77eeca5
Show file tree
Hide file tree
Showing 41 changed files with 3,543 additions and 96 deletions.
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

0 comments on commit 77eeca5

Please sign in to comment.