@@ -106,6 +106,46 @@ def test_t_us_core_v4(self, test_name):
106
106
"""This is a fake metric, designed just to test profile validity detection"""
107
107
self .run_study ("t_us_core_v4" , test = test_name )
108
108
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
+
109
149
# **********************************
110
150
# ** Support code below this line **
111
151
# **********************************
@@ -114,6 +154,16 @@ def setUp(self):
114
154
super ().setUp ()
115
155
self .maxDiff = None
116
156
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
+
117
167
def run_study (
118
168
self ,
119
169
metric : str ,
@@ -143,14 +193,7 @@ def run_study(
143
193
f"{ tmpdir } /cumulus_library_data_metrics" ,
144
194
)
145
195
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 ()
154
197
155
198
# But change the manifest to only run one test metric, for speed reasons
156
199
manifest_file = f"{ tmpdir } /cumulus_library_data_metrics/manifest.toml"
0 commit comments