roc-film 1.13.4__py3-none-any.whl → 1.14.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- roc/__init__.py +2 -1
- roc/film/__init__.py +2 -2
- roc/film/commands.py +372 -323
- roc/film/config/__init__.py +0 -1
- roc/film/constants.py +101 -65
- roc/film/descriptor.json +126 -95
- roc/film/exceptions.py +28 -27
- roc/film/tasks/__init__.py +16 -16
- roc/film/tasks/cat_solo_hk.py +86 -74
- roc/film/tasks/cdf_postpro.py +438 -309
- roc/film/tasks/check_dds.py +39 -45
- roc/film/tasks/db_to_anc_bia_sweep_table.py +381 -0
- roc/film/tasks/dds_to_l0.py +232 -180
- roc/film/tasks/export_solo_coord.py +147 -0
- roc/film/tasks/file_handler.py +91 -75
- roc/film/tasks/l0_to_hk.py +117 -103
- roc/film/tasks/l0_to_l1_bia_current.py +38 -30
- roc/film/tasks/l0_to_l1_bia_sweep.py +417 -329
- roc/film/tasks/l0_to_l1_sbm.py +250 -208
- roc/film/tasks/l0_to_l1_surv.py +185 -130
- roc/film/tasks/make_daily_tm.py +40 -37
- roc/film/tasks/merge_tcreport.py +77 -71
- roc/film/tasks/merge_tmraw.py +102 -89
- roc/film/tasks/parse_dds_xml.py +21 -20
- roc/film/tasks/set_l0_utc.py +51 -49
- roc/film/tests/cdf_compare.py +565 -0
- roc/film/tests/hdf5_compare.py +84 -62
- roc/film/tests/test_dds_to_l0.py +93 -51
- roc/film/tests/test_dds_to_tc.py +8 -11
- roc/film/tests/test_dds_to_tm.py +8 -10
- roc/film/tests/test_film.py +161 -116
- roc/film/tests/test_l0_to_hk.py +64 -36
- roc/film/tests/test_l0_to_l1_bia.py +10 -14
- roc/film/tests/test_l0_to_l1_sbm.py +14 -19
- roc/film/tests/test_l0_to_l1_surv.py +68 -41
- roc/film/tests/test_metadata.py +21 -20
- roc/film/tests/tests.py +743 -396
- roc/film/tools/__init__.py +5 -5
- roc/film/tools/dataset_tasks.py +34 -2
- roc/film/tools/file_helpers.py +390 -269
- roc/film/tools/l0.py +402 -324
- roc/film/tools/metadata.py +147 -127
- roc/film/tools/skeleton.py +12 -17
- roc/film/tools/tools.py +109 -92
- roc/film/tools/xlsx2skt.py +161 -139
- {roc_film-1.13.4.dist-info → roc_film-1.14.0.dist-info}/LICENSE +127 -125
- roc_film-1.14.0.dist-info/METADATA +60 -0
- roc_film-1.14.0.dist-info/RECORD +50 -0
- {roc_film-1.13.4.dist-info → roc_film-1.14.0.dist-info}/WHEEL +1 -1
- roc/film/tasks/l0_to_anc_bia_sweep_table.py +0 -348
- roc_film-1.13.4.dist-info/METADATA +0 -120
- roc_film-1.13.4.dist-info/RECORD +0 -48
roc/film/tests/test_film.py
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
"""
|
5
5
|
Tests module for the roc.film plugin.
|
6
6
|
"""
|
7
|
+
|
7
8
|
import glob
|
8
9
|
import shlex
|
9
10
|
import tarfile
|
@@ -18,21 +19,25 @@ from poppy.core.conf import settings
|
|
18
19
|
|
19
20
|
class FilmTest:
|
20
21
|
# Base URL for downloading test data for FILM plugin
|
21
|
-
base_url =
|
22
|
+
base_url = (
|
23
|
+
"https://rpw.lesia.obspm.fr/roc/data/private/devtest/roc/test_data/rodp/film"
|
24
|
+
)
|
22
25
|
|
23
26
|
# test credentials
|
24
|
-
host =
|
25
|
-
username = os.environ.get(
|
27
|
+
host = "roc2-dev.obspm.fr"
|
28
|
+
username = os.environ.get("ROC_TEST_USER", "roctest")
|
26
29
|
password = None
|
27
30
|
|
28
31
|
def __init__(self):
|
29
|
-
logger.debug(
|
30
|
-
logger.debug(f
|
32
|
+
logger.debug("FilmTest setup_class()")
|
33
|
+
logger.debug(f"base_url = {self.base_url}")
|
31
34
|
try:
|
32
|
-
self.password = os.environ[
|
35
|
+
self.password = os.environ["ROC_TEST_PASSWORD"]
|
33
36
|
except KeyError:
|
34
|
-
raise KeyError(
|
35
|
-
|
37
|
+
raise KeyError(
|
38
|
+
"You have to define the test user password using"
|
39
|
+
'the "ROC_TEST_PASSWORD" environment variable'
|
40
|
+
)
|
36
41
|
|
37
42
|
@staticmethod
|
38
43
|
def get_test_data_path(command=None):
|
@@ -44,16 +49,18 @@ class FilmTest:
|
|
44
49
|
:return: data_test_path, string containing the path
|
45
50
|
"""
|
46
51
|
# Define default value
|
47
|
-
data_test_path = os.path.join(tempfile.gettempdir(),
|
52
|
+
data_test_path = os.path.join(tempfile.gettempdir(), "roc", "film")
|
48
53
|
|
49
54
|
# Get pipeline configuration parameters
|
50
55
|
conf = FilmTest.load_configuration()
|
51
56
|
|
52
57
|
# Check if ROC_TEST_DATA_PATH env. variable is defined
|
53
58
|
# in: (1) config file, (2) shell env.
|
54
|
-
for source in [conf[
|
59
|
+
for source in [conf["environment"], os.environ]:
|
55
60
|
try:
|
56
|
-
data_test_path = os.path.join(
|
61
|
+
data_test_path = os.path.join(
|
62
|
+
source["ROC_TEST_DATA_PATH"], "roc", "film"
|
63
|
+
)
|
57
64
|
except Exception:
|
58
65
|
# logger.debug('Env. variable ROC_TEST_DATA_PATH not set')
|
59
66
|
pass
|
@@ -63,19 +70,22 @@ class FilmTest:
|
|
63
70
|
if command:
|
64
71
|
data_test_path = os.path.join(data_test_path, command.lower())
|
65
72
|
|
66
|
-
logger.info(f
|
73
|
+
logger.info(f"Using {data_test_path} to store test data")
|
67
74
|
# Make sure the directory exists (ignore if it does)
|
68
75
|
Path(data_test_path).mkdir(parents=True, exist_ok=True)
|
69
76
|
|
70
77
|
return data_test_path
|
71
78
|
|
72
|
-
def get_test_data(
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
def get_test_data(
|
80
|
+
self,
|
81
|
+
command,
|
82
|
+
base_url=None,
|
83
|
+
test_data_dir=None,
|
84
|
+
test_data_file="test_data.tar.gz",
|
85
|
+
target_dir=None,
|
86
|
+
overwrite=False,
|
87
|
+
extract=True,
|
88
|
+
):
|
79
89
|
"""
|
80
90
|
Try to get data for the current FILM command test.
|
81
91
|
|
@@ -106,25 +116,26 @@ class FilmTest:
|
|
106
116
|
auth = (self.username, self.password)
|
107
117
|
|
108
118
|
if not os.path.isfile(test_data_path) or overwrite:
|
109
|
-
|
110
119
|
# Build complete URL and download file
|
111
|
-
test_data_url =
|
120
|
+
test_data_url = "/".join([base_url, command, test_data_file])
|
112
121
|
if all([val is not None for val in auth]):
|
113
|
-
logger.info(f
|
122
|
+
logger.info(f"Downloading {test_data_url} in {test_data_dir} ...")
|
114
123
|
download_file(test_data_path, test_data_url, auth=auth)
|
115
124
|
else:
|
116
|
-
raise IOError(
|
125
|
+
raise IOError(
|
126
|
+
"At least one of the following arguments missing: [username, password]!"
|
127
|
+
)
|
117
128
|
|
118
129
|
else:
|
119
|
-
logger.info(f
|
130
|
+
logger.info(f"{test_data_path} already exists")
|
120
131
|
|
121
132
|
if extract:
|
122
133
|
if tarfile.is_tarfile(str(test_data_path)):
|
123
|
-
logger.info(f
|
124
|
-
with tarfile.open(str(test_data_path),
|
125
|
-
tarball.extractall(path=target_dir)
|
134
|
+
logger.info(f"Extracting {test_data_path} ...")
|
135
|
+
with tarfile.open(str(test_data_path), "r:*") as tarball:
|
136
|
+
tarball.extractall(path=target_dir, filter="fully_trusted")
|
126
137
|
else:
|
127
|
-
raise tarfile.ReadError(f
|
138
|
+
raise tarfile.ReadError(f"{test_data_path} is not a valid tarball!")
|
128
139
|
|
129
140
|
return test_data_path
|
130
141
|
|
@@ -135,9 +146,14 @@ class FilmTest:
|
|
135
146
|
|
136
147
|
:return: output_dir_path, string containing the path
|
137
148
|
"""
|
149
|
+
# Initialize output
|
150
|
+
output_dir_path = ""
|
151
|
+
|
138
152
|
# Define value using command name
|
139
153
|
if command:
|
140
|
-
output_dir_path = os.path.join(
|
154
|
+
output_dir_path = os.path.join(
|
155
|
+
FilmTest.get_test_data_path(command), "output"
|
156
|
+
)
|
141
157
|
else:
|
142
158
|
# Else attempt to get from config file or env variables.
|
143
159
|
# Get pipeline configuration parameters
|
@@ -145,16 +161,20 @@ class FilmTest:
|
|
145
161
|
|
146
162
|
# Check if pipeline.output_path variable is defined in config
|
147
163
|
try:
|
148
|
-
output_dir_path = conf[
|
164
|
+
output_dir_path = conf["pipeline"]["output_path"]
|
149
165
|
except KeyError:
|
150
|
-
logger.debug(
|
166
|
+
logger.debug(
|
167
|
+
"Variable pipeline.output_path not set in the config. file!"
|
168
|
+
)
|
151
169
|
else:
|
152
|
-
if output_dir_path.startswith(
|
153
|
-
output_dir_path = output_dir_path.replace(
|
170
|
+
if output_dir_path.startswith("$ROOT_DIRECTORY"):
|
171
|
+
output_dir_path = output_dir_path.replace(
|
172
|
+
"$ROOT_DIRECTORY", settings.ROOT_DIRECTORY
|
173
|
+
)
|
154
174
|
|
155
175
|
# Create directory
|
156
176
|
Path(output_dir_path).mkdir(exist_ok=True, parents=True)
|
157
|
-
logger.debug(f
|
177
|
+
logger.debug(f"Using {output_dir_path} to store data produced during the test")
|
158
178
|
|
159
179
|
return output_dir_path
|
160
180
|
|
@@ -166,15 +186,18 @@ class FilmTest:
|
|
166
186
|
:param test_data_dir: Root path of the test data directory
|
167
187
|
:return: tuple (input_dir_path, inputs)
|
168
188
|
"""
|
169
|
-
input_dir_path = os.path.join(test_data_dir,
|
189
|
+
input_dir_path = os.path.join(test_data_dir, "inputs")
|
170
190
|
if not os.path.isdir(input_dir_path):
|
171
|
-
logger.warning(f
|
191
|
+
logger.warning(f"{input_dir_path} not found")
|
172
192
|
inputs = list()
|
173
193
|
else:
|
174
|
-
inputs = [
|
175
|
-
|
194
|
+
inputs = [
|
195
|
+
item
|
196
|
+
for item in os.listdir(input_dir_path)
|
197
|
+
if os.path.isfile(os.path.join(input_dir_path, item))
|
198
|
+
]
|
176
199
|
if len(inputs) == 0:
|
177
|
-
logger.warning(f
|
200
|
+
logger.warning(f"No input file found in {input_dir_path}")
|
178
201
|
|
179
202
|
return input_dir_path, inputs
|
180
203
|
|
@@ -186,15 +209,18 @@ class FilmTest:
|
|
186
209
|
:param test_data_dir: Root path of the test data directory
|
187
210
|
:return: tuple (expected_output_dir_path, expected_outputs)
|
188
211
|
"""
|
189
|
-
expected_output_dir_path = os.path.join(test_data_dir,
|
212
|
+
expected_output_dir_path = os.path.join(test_data_dir, "expected_outputs")
|
190
213
|
if not os.path.isdir(expected_output_dir_path):
|
191
|
-
logger.warning(f
|
214
|
+
logger.warning(f"{expected_output_dir_path} not found")
|
192
215
|
expected_outputs = list()
|
193
216
|
else:
|
194
|
-
expected_outputs = [
|
195
|
-
|
217
|
+
expected_outputs = [
|
218
|
+
item
|
219
|
+
for item in os.listdir(expected_output_dir_path)
|
220
|
+
if os.path.isfile(os.path.join(expected_output_dir_path, item))
|
221
|
+
]
|
196
222
|
if len(expected_outputs) == 0:
|
197
|
-
logger.warning(f
|
223
|
+
logger.warning(f"No input file found in {expected_output_dir_path}")
|
198
224
|
|
199
225
|
return expected_output_dir_path, expected_outputs
|
200
226
|
|
@@ -206,18 +232,18 @@ class FilmTest:
|
|
206
232
|
:return: spice_kernels_dir
|
207
233
|
"""
|
208
234
|
# Define default value
|
209
|
-
spice_kernels_dir = os.path.join(Path.cwd(),
|
235
|
+
spice_kernels_dir = os.path.join(Path.cwd(), "data", "spice_kernels")
|
210
236
|
|
211
237
|
# Get pipeline configuration parameters
|
212
238
|
conf = FilmTest.load_configuration()
|
213
239
|
|
214
240
|
# Check if SPICE_KERNEL_PATH env. variable is defined
|
215
241
|
# in: (1) config file, (2) shell env.
|
216
|
-
for source in [conf[
|
242
|
+
for source in [conf["environment"], os.environ]:
|
217
243
|
try:
|
218
|
-
spice_kernels_dir = os.path.join(source[
|
219
|
-
except Exception:
|
220
|
-
|
244
|
+
spice_kernels_dir = os.path.join(source["SPICE_KERNEL_PATH"])
|
245
|
+
except Exception as e:
|
246
|
+
logger.debug(e)
|
221
247
|
pass
|
222
248
|
else:
|
223
249
|
break
|
@@ -225,18 +251,20 @@ class FilmTest:
|
|
225
251
|
return spice_kernels_dir
|
226
252
|
|
227
253
|
@staticmethod
|
228
|
-
def get_diff_files(dirs_cmp, path=
|
254
|
+
def get_diff_files(dirs_cmp, path=""):
|
229
255
|
for name in dirs_cmp.diff_files:
|
230
256
|
yield os.path.join(path, name)
|
231
257
|
for parent, sub_dirs_cmp in dirs_cmp.subdirs.items():
|
232
|
-
for filepath in FilmTest.get_diff_files(
|
258
|
+
for filepath in FilmTest.get_diff_files(
|
259
|
+
sub_dirs_cmp, path=os.path.join(path, parent)
|
260
|
+
):
|
233
261
|
yield filepath
|
234
262
|
|
235
263
|
@staticmethod
|
236
264
|
def load_configuration():
|
237
265
|
from poppy.core.configuration import Configuration
|
238
266
|
|
239
|
-
configuration = Configuration(os.getenv(
|
267
|
+
configuration = Configuration(os.getenv("PIPELINE_CONFIG_FILE", None))
|
240
268
|
configuration.read()
|
241
269
|
|
242
270
|
return configuration
|
@@ -249,34 +277,36 @@ class FilmTest:
|
|
249
277
|
:return: idb_release_dir_path, string containing the path
|
250
278
|
"""
|
251
279
|
# Define default value
|
252
|
-
idb_release_dir_path = os.path.join(tempfile.gettempdir(),
|
280
|
+
idb_release_dir_path = os.path.join(tempfile.gettempdir(), "roc", "idb_release")
|
253
281
|
|
254
282
|
# Get pipeline configuration parameters
|
255
283
|
conf = FilmTest.load_configuration()
|
256
284
|
|
257
285
|
# Check if IDB_INSTALL_DIR env. variable is defined
|
258
286
|
# in: (1) config file, (2) shell env.
|
259
|
-
for source in [conf[
|
287
|
+
for source in [conf["environment"], os.environ]:
|
260
288
|
try:
|
261
|
-
|
262
|
-
except Exception:
|
263
|
-
|
289
|
+
_ = os.path.join(source["IDB_INSTALL_DIR"])
|
290
|
+
except Exception as e:
|
291
|
+
logger.debug(e)
|
264
292
|
pass
|
265
293
|
else:
|
266
294
|
break
|
267
295
|
|
268
|
-
logger.info(f
|
296
|
+
logger.info(f"Using {idb_release_dir_path} to store RPW IDB source files")
|
269
297
|
|
270
298
|
return idb_release_dir_path
|
271
299
|
|
272
300
|
@staticmethod
|
273
|
-
def load_idb(
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
301
|
+
def load_idb(
|
302
|
+
test_class_instance,
|
303
|
+
idb_version=None,
|
304
|
+
idb_dump_file=None,
|
305
|
+
user=os.environ.get("ROC_TEST_USER", "roctest"),
|
306
|
+
password=os.environ.get("ROC_TEST_PASSWORD", None),
|
307
|
+
install_dir=None,
|
308
|
+
log_level="ERROR",
|
309
|
+
):
|
280
310
|
"""
|
281
311
|
Function that gathers commands to load IDB in the database.
|
282
312
|
|
@@ -291,7 +321,7 @@ class FilmTest:
|
|
291
321
|
"""
|
292
322
|
|
293
323
|
# Make sure to have an up-and-running database
|
294
|
-
test_class_instance.run_command(
|
324
|
+
test_class_instance.run_command("pop db upgrade heads -ll INFO")
|
295
325
|
|
296
326
|
if not install_dir:
|
297
327
|
install_dir = FilmTest.get_idb_release_dir_path()
|
@@ -300,50 +330,51 @@ class FilmTest:
|
|
300
330
|
# Loading IDB dump file in the database
|
301
331
|
# (required a valid dump file and psql command line tool)
|
302
332
|
command = [
|
303
|
-
|
304
|
-
|
333
|
+
"pop",
|
334
|
+
"-ll",
|
305
335
|
log_level,
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
336
|
+
"idb",
|
337
|
+
"--force",
|
338
|
+
"load_idb_dump",
|
339
|
+
"--i",
|
310
340
|
install_dir,
|
311
|
-
|
341
|
+
"-d",
|
312
342
|
idb_dump_file,
|
313
|
-
|
314
|
-
user,
|
343
|
+
"-a",
|
344
|
+
user,
|
345
|
+
password,
|
315
346
|
]
|
316
347
|
test_class_instance.run_command(command)
|
317
348
|
elif idb_version:
|
318
349
|
# Load PALISADE IDB first (always)
|
319
350
|
idb_palisade_loading = [
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
351
|
+
"pop",
|
352
|
+
"idb",
|
353
|
+
"install",
|
354
|
+
"-i",
|
324
355
|
install_dir,
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
356
|
+
"-s",
|
357
|
+
"PALISADE",
|
358
|
+
"-v",
|
359
|
+
"4.3.5_MEB_PFM",
|
360
|
+
"--load",
|
361
|
+
"-ll",
|
331
362
|
log_level,
|
332
363
|
]
|
333
364
|
|
334
365
|
# Then load MIB
|
335
366
|
idb_mib_loading = [
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
367
|
+
"pop",
|
368
|
+
"idb",
|
369
|
+
"install",
|
370
|
+
"-i",
|
340
371
|
install_dir,
|
341
|
-
|
342
|
-
|
343
|
-
|
372
|
+
"-s",
|
373
|
+
"MIB",
|
374
|
+
"-v",
|
344
375
|
idb_version,
|
345
|
-
|
346
|
-
|
376
|
+
"--load",
|
377
|
+
"-ll",
|
347
378
|
log_level,
|
348
379
|
]
|
349
380
|
|
@@ -353,12 +384,16 @@ class FilmTest:
|
|
353
384
|
# Apply IDB loading
|
354
385
|
test_class_instance.run_command(idb_mib_loading)
|
355
386
|
else:
|
356
|
-
raise ValueError(
|
387
|
+
raise ValueError("Missing input argument to load IDB!")
|
357
388
|
|
358
389
|
@staticmethod
|
359
|
-
def load_l0(
|
360
|
-
|
361
|
-
|
390
|
+
def load_l0(
|
391
|
+
test_class_instance,
|
392
|
+
l0_dir_path,
|
393
|
+
idb_version,
|
394
|
+
idb_source="MIB",
|
395
|
+
pattern="solo_L0_rpw*.h5",
|
396
|
+
):
|
362
397
|
"""
|
363
398
|
Insert L0 data in the database (required to run some tests)
|
364
399
|
|
@@ -374,32 +409,42 @@ class FilmTest:
|
|
374
409
|
# Get SCLK and LSK SPICE kernels
|
375
410
|
kernels_dir = FilmTest.get_spice_kernel_dir()
|
376
411
|
try:
|
377
|
-
sclk_file = sorted(
|
378
|
-
|
379
|
-
|
412
|
+
sclk_file = sorted(
|
413
|
+
list(glob.glob(os.path.join(kernels_dir, "sclk", "*.tsc")))
|
414
|
+
)[-1]
|
415
|
+
except Exception as e:
|
416
|
+
logger.exception(f"No SPICE SCLK kernel loaded:\n{e}")
|
417
|
+
raise
|
380
418
|
else:
|
381
|
-
logger.info(f
|
419
|
+
logger.info(f"Use {sclk_file}")
|
382
420
|
try:
|
383
|
-
lsk_file = sorted(
|
384
|
-
|
385
|
-
|
421
|
+
lsk_file = sorted(
|
422
|
+
list(glob.glob(os.path.join(kernels_dir, "lsk", "*.tls")))
|
423
|
+
)[-1]
|
424
|
+
except Exception as e:
|
425
|
+
logger.exception(f"No SPICE LSK kernel loaded:\n{e}")
|
426
|
+
raise
|
386
427
|
else:
|
387
|
-
logger.info(f
|
428
|
+
logger.info(f"Use {lsk_file}")
|
388
429
|
|
389
430
|
# Inserting L0 data into the database
|
390
|
-
cmd =
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
431
|
+
cmd = " ".join(
|
432
|
+
[
|
433
|
+
"pop",
|
434
|
+
"-ll INFO",
|
435
|
+
"dingo",
|
436
|
+
f"--idb-version {idb_version}",
|
437
|
+
f"--idb-source {idb_source}",
|
438
|
+
f"--sclk {sclk_file}",
|
439
|
+
f"--lsk {lsk_file}",
|
440
|
+
"l0_to_db",
|
441
|
+
"-l0 " + " ".join(l0_files_path),
|
442
|
+
]
|
443
|
+
)
|
399
444
|
logger.debug(cmd)
|
400
445
|
test_class_instance.run_command(shlex.split(cmd))
|
401
446
|
|
402
447
|
# Inserting HFR time info in the database
|
403
|
-
cmd =
|
448
|
+
cmd = "pop -ll INFO dingo l0_to_hfrtimelog -l0 " + " ".join(l0_files_path)
|
404
449
|
logger.debug(cmd)
|
405
450
|
test_class_instance.run_command(shlex.split(cmd))
|
roc/film/tests/test_l0_to_hk.py
CHANGED
@@ -14,7 +14,7 @@ import pytest
|
|
14
14
|
import shutil
|
15
15
|
import unittest.mock as mock
|
16
16
|
|
17
|
-
from
|
17
|
+
from roc.film.tests.cdf_compare import cdf_compare
|
18
18
|
|
19
19
|
from poppy.core.logger import logger
|
20
20
|
from poppy.core.test import CommandTestCase
|
@@ -25,7 +25,7 @@ from roc.film.tests.test_film import FilmTest
|
|
25
25
|
class TestL0ToHk(CommandTestCase):
|
26
26
|
film = FilmTest()
|
27
27
|
|
28
|
-
cmd =
|
28
|
+
cmd = "l0_to_hk"
|
29
29
|
|
30
30
|
def setup_method(self, method):
|
31
31
|
super().setup_method(method)
|
@@ -46,15 +46,18 @@ class TestL0ToHk(CommandTestCase):
|
|
46
46
|
# clear the files produced during test
|
47
47
|
shutil.rmtree(self.output_dir_path)
|
48
48
|
|
49
|
-
|
50
|
-
@pytest.mark.parametrize(
|
51
|
-
|
52
|
-
|
49
|
+
# @pytest.mark.skip()
|
50
|
+
@pytest.mark.parametrize(
|
51
|
+
"idb_source,idb_version",
|
52
|
+
[
|
53
|
+
("MIB", "20200131"),
|
54
|
+
],
|
55
|
+
)
|
53
56
|
def test_l0_to_hk(self, idb_source, idb_version):
|
54
57
|
from poppy.core.conf import Settings
|
55
58
|
|
56
59
|
# Name of the command to test
|
57
|
-
cmd =
|
60
|
+
cmd = "l0_to_hk"
|
58
61
|
|
59
62
|
# Retrieve data for current test
|
60
63
|
test_data_path = FilmTest().get_test_data(cmd, extract=True)
|
@@ -64,46 +67,69 @@ class TestL0ToHk(CommandTestCase):
|
|
64
67
|
# Initialize inputs and expected outputs
|
65
68
|
input_dir_path, inputs = FilmTest.get_inputs(test_data_dir)
|
66
69
|
if not inputs:
|
67
|
-
raise FileNotFoundError(f
|
68
|
-
expected_output_dir_path, expected_outputs = FilmTest.get_expected_outputs(
|
70
|
+
raise FileNotFoundError(f"No input found in {test_data_dir}!")
|
71
|
+
expected_output_dir_path, expected_outputs = FilmTest.get_expected_outputs(
|
72
|
+
test_data_dir
|
73
|
+
)
|
69
74
|
if not expected_outputs:
|
70
|
-
raise FileNotFoundError(f
|
75
|
+
raise FileNotFoundError(f"No expected output found in {test_data_dir}!")
|
71
76
|
|
72
77
|
# Initialize directory where files produced during test will be saved
|
73
|
-
output_dir_path = os.path.join(test_data_dir,
|
78
|
+
output_dir_path = os.path.join(test_data_dir, "output")
|
74
79
|
self.output_dir_path = output_dir_path
|
75
80
|
|
76
81
|
# Check that SPICE kernels are present in ./data/spice_kernels folder
|
77
82
|
spice_kernels_dir = FilmTest.get_spice_kernel_dir()
|
78
83
|
if not os.path.isdir(spice_kernels_dir):
|
79
|
-
raise FileNotFoundError(
|
84
|
+
raise FileNotFoundError(
|
85
|
+
f"No SPICE kernel set found in {spice_kernels_dir}!"
|
86
|
+
)
|
80
87
|
|
81
88
|
# initialize the main command
|
82
|
-
command_to_test =
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
command_to_test = " ".join(
|
90
|
+
[
|
91
|
+
"pop",
|
92
|
+
"film",
|
93
|
+
"--force",
|
94
|
+
"--idb-version",
|
95
|
+
idb_version,
|
96
|
+
"--idb-source",
|
97
|
+
idb_source,
|
98
|
+
cmd,
|
99
|
+
os.path.join(input_dir_path, inputs[0]),
|
100
|
+
"--output-dir",
|
101
|
+
output_dir_path,
|
102
|
+
"-ll",
|
103
|
+
"INFO",
|
104
|
+
]
|
105
|
+
)
|
91
106
|
|
92
107
|
# define the required plugins
|
93
|
-
plugin_list = [
|
108
|
+
plugin_list = [
|
109
|
+
"poppy.pop",
|
110
|
+
"roc.idb",
|
111
|
+
"roc.rpl",
|
112
|
+
"roc.rap",
|
113
|
+
"roc.dingo",
|
114
|
+
"roc.film",
|
115
|
+
]
|
94
116
|
|
95
117
|
# run the command
|
96
118
|
# force the value of the plugin list
|
97
|
-
with mock.patch.object(
|
98
|
-
|
99
|
-
|
119
|
+
with mock.patch.object(
|
120
|
+
Settings,
|
121
|
+
"configure",
|
122
|
+
autospec=True,
|
123
|
+
side_effect=self.mock_configure_settings(
|
124
|
+
dictionary={"PLUGINS": plugin_list}
|
125
|
+
),
|
126
|
+
):
|
100
127
|
# Load IDB in the database
|
101
128
|
FilmTest.load_idb(self, idb_version=idb_version)
|
102
129
|
self.run_command(shlex.split(command_to_test))
|
103
130
|
|
104
131
|
# compare directory content
|
105
|
-
dirs_cmp = filecmp.dircmp(output_dir_path,
|
106
|
-
expected_output_dir_path)
|
132
|
+
dirs_cmp = filecmp.dircmp(output_dir_path, expected_output_dir_path)
|
107
133
|
|
108
134
|
dirs_cmp.report()
|
109
135
|
|
@@ -112,23 +138,25 @@ class TestL0ToHk(CommandTestCase):
|
|
112
138
|
|
113
139
|
for filename in FilmTest.get_diff_files(dirs_cmp):
|
114
140
|
# compare only cdf files with differences
|
115
|
-
if filename.endswith(
|
141
|
+
if filename.endswith(".cdf"):
|
116
142
|
# use cdf compare to compute the differences between expected output and the command output
|
117
143
|
result = cdf_compare(
|
118
144
|
os.path.join(output_dir_path, filename),
|
119
145
|
os.path.join(expected_output_dir_path, filename),
|
120
146
|
list_ignore_gatt=[
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
]
|
147
|
+
"File_ID",
|
148
|
+
"Generation_date",
|
149
|
+
"Pipeline_version",
|
150
|
+
"Pipeline_name",
|
151
|
+
"Software_version",
|
152
|
+
"IDB_version",
|
153
|
+
],
|
128
154
|
)
|
129
155
|
|
130
156
|
# compare the difference dict with the expected one
|
131
157
|
if result:
|
132
|
-
logger.error(
|
158
|
+
logger.error(
|
159
|
+
f"Differences between expected output and the command output: {pformat(result)}"
|
160
|
+
)
|
133
161
|
|
134
162
|
assert result == {}
|