Skip to content

Commit a98186b

Browse files
authored
Merge pull request #72 from smart-on-fhir/mikix/fix-export-names
fix: exporting was broken because of a typo
2 parents e596818 + 144597e commit a98186b

File tree

3 files changed

+54
-10
lines changed

3 files changed

+54
-10
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Data Metrics study for Cumulus Library"""
22

3-
__version__ = "7.0.0"
3+
__version__ = "7.0.1"

cumulus_library_data_metrics/manifest.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ count_list = [
6969
"count_c_us_core_v4_count_diagnosticreport_lab_must_support",
7070
"count_c_us_core_v4_count_diagnosticreport_note_mandatory",
7171
"count_c_us_core_v4_count_diagnosticreport_note_must_support",
72-
"count_c_us_core_v4_count_documentreference_mandatory",
72+
"count_c_us_core_v4_count_documentreference_mandatory1",
73+
"count_c_us_core_v4_count_documentreference_mandatory2",
7374
"count_c_us_core_v4_count_documentreference_must_support",
7475
"count_c_us_core_v4_count_encounter_mandatory",
7576
"count_c_us_core_v4_count_encounter_must_support",

tests/test_metrics.py

+51-8
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,46 @@ def test_t_us_core_v4(self, test_name):
106106
"""This is a fake metric, designed just to test profile validity detection"""
107107
self.run_study("t_us_core_v4", test=test_name)
108108

109+
def test_end_to_end_no_data(self):
110+
"""
111+
Just validate that the machinery works, from building to exporting.
112+
113+
This can catch manifest typos and the like.
114+
"""
115+
test_dir = os.path.dirname(__file__)
116+
root_dir = os.path.dirname(test_dir)
117+
118+
self.reset_test_modules()
119+
120+
with tempfile.TemporaryDirectory() as tmpdir:
121+
cli.main(
122+
[
123+
"build",
124+
"--target=data_metrics",
125+
f"--study-dir={root_dir}/cumulus_library_data_metrics",
126+
"--db-type=duckdb",
127+
f"--database={tmpdir}/duck.db",
128+
f"--load-ndjson-dir={tmpdir}", # no data
129+
]
130+
)
131+
cli.main(
132+
[
133+
"export",
134+
tmpdir,
135+
"--target=data_metrics",
136+
f"--study-dir={root_dir}/cumulus_library_data_metrics",
137+
"--db-type=duckdb",
138+
f"--database={tmpdir}/duck.db",
139+
]
140+
)
141+
142+
# Spot check an exported file
143+
self.assertTrue(
144+
os.path.exists(
145+
f"{tmpdir}/data_metrics/data_metrics__count_c_system_use_device_type.cube.csv"
146+
)
147+
)
148+
109149
# **********************************
110150
# ** Support code below this line **
111151
# **********************************
@@ -114,6 +154,16 @@ def setUp(self):
114154
super().setUp()
115155
self.maxDiff = None
116156

157+
def reset_test_modules(self):
158+
# Because we reload the data-metrics study from different paths each time,
159+
# python might be keeping the stale imports from previous test builders around.
160+
# Manually drop em here.
161+
stale_modules = [
162+
mod for mod in sys.modules if mod.startswith("cumulus_library_data_metrics")
163+
]
164+
for mod in stale_modules:
165+
del sys.modules[mod]
166+
117167
def run_study(
118168
self,
119169
metric: str,
@@ -143,14 +193,7 @@ def run_study(
143193
f"{tmpdir}/cumulus_library_data_metrics",
144194
)
145195

146-
# Because we reload the data-metrics study from different paths each time,
147-
# python might be keeping the stale imports from previous test builders around.
148-
# Manually drop em here.
149-
stale_modules = [
150-
mod for mod in sys.modules if mod.startswith("cumulus_library_data_metrics")
151-
]
152-
for mod in stale_modules:
153-
del sys.modules[mod]
196+
self.reset_test_modules()
154197

155198
# But change the manifest to only run one test metric, for speed reasons
156199
manifest_file = f"{tmpdir}/cumulus_library_data_metrics/manifest.toml"

0 commit comments

Comments
 (0)