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.
Files changed (52) hide show
  1. roc/__init__.py +2 -1
  2. roc/film/__init__.py +2 -2
  3. roc/film/commands.py +372 -323
  4. roc/film/config/__init__.py +0 -1
  5. roc/film/constants.py +101 -65
  6. roc/film/descriptor.json +126 -95
  7. roc/film/exceptions.py +28 -27
  8. roc/film/tasks/__init__.py +16 -16
  9. roc/film/tasks/cat_solo_hk.py +86 -74
  10. roc/film/tasks/cdf_postpro.py +438 -309
  11. roc/film/tasks/check_dds.py +39 -45
  12. roc/film/tasks/db_to_anc_bia_sweep_table.py +381 -0
  13. roc/film/tasks/dds_to_l0.py +232 -180
  14. roc/film/tasks/export_solo_coord.py +147 -0
  15. roc/film/tasks/file_handler.py +91 -75
  16. roc/film/tasks/l0_to_hk.py +117 -103
  17. roc/film/tasks/l0_to_l1_bia_current.py +38 -30
  18. roc/film/tasks/l0_to_l1_bia_sweep.py +417 -329
  19. roc/film/tasks/l0_to_l1_sbm.py +250 -208
  20. roc/film/tasks/l0_to_l1_surv.py +185 -130
  21. roc/film/tasks/make_daily_tm.py +40 -37
  22. roc/film/tasks/merge_tcreport.py +77 -71
  23. roc/film/tasks/merge_tmraw.py +102 -89
  24. roc/film/tasks/parse_dds_xml.py +21 -20
  25. roc/film/tasks/set_l0_utc.py +51 -49
  26. roc/film/tests/cdf_compare.py +565 -0
  27. roc/film/tests/hdf5_compare.py +84 -62
  28. roc/film/tests/test_dds_to_l0.py +93 -51
  29. roc/film/tests/test_dds_to_tc.py +8 -11
  30. roc/film/tests/test_dds_to_tm.py +8 -10
  31. roc/film/tests/test_film.py +161 -116
  32. roc/film/tests/test_l0_to_hk.py +64 -36
  33. roc/film/tests/test_l0_to_l1_bia.py +10 -14
  34. roc/film/tests/test_l0_to_l1_sbm.py +14 -19
  35. roc/film/tests/test_l0_to_l1_surv.py +68 -41
  36. roc/film/tests/test_metadata.py +21 -20
  37. roc/film/tests/tests.py +743 -396
  38. roc/film/tools/__init__.py +5 -5
  39. roc/film/tools/dataset_tasks.py +34 -2
  40. roc/film/tools/file_helpers.py +390 -269
  41. roc/film/tools/l0.py +402 -324
  42. roc/film/tools/metadata.py +147 -127
  43. roc/film/tools/skeleton.py +12 -17
  44. roc/film/tools/tools.py +109 -92
  45. roc/film/tools/xlsx2skt.py +161 -139
  46. {roc_film-1.13.4.dist-info → roc_film-1.14.0.dist-info}/LICENSE +127 -125
  47. roc_film-1.14.0.dist-info/METADATA +60 -0
  48. roc_film-1.14.0.dist-info/RECORD +50 -0
  49. {roc_film-1.13.4.dist-info → roc_film-1.14.0.dist-info}/WHEEL +1 -1
  50. roc/film/tasks/l0_to_anc_bia_sweep_table.py +0 -348
  51. roc_film-1.13.4.dist-info/METADATA +0 -120
  52. roc_film-1.13.4.dist-info/RECORD +0 -48
@@ -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 = 'https://rpw.lesia.obspm.fr/roc/data/private/devtest/roc/test_data/rodp/film'
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 = 'roc2-dev.obspm.fr'
25
- username = os.environ.get('ROC_TEST_USER', 'roctest')
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('FilmTest setup_class()')
30
- logger.debug(f'base_url = {self.base_url}')
32
+ logger.debug("FilmTest setup_class()")
33
+ logger.debug(f"base_url = {self.base_url}")
31
34
  try:
32
- self.password = os.environ['ROC_TEST_PASSWORD']
35
+ self.password = os.environ["ROC_TEST_PASSWORD"]
33
36
  except KeyError:
34
- raise KeyError('You have to define the test user password using'
35
- 'the "ROC_TEST_PASSWORD" environment variable')
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(), 'roc', 'film')
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['environment'], os.environ]:
59
+ for source in [conf["environment"], os.environ]:
55
60
  try:
56
- data_test_path = os.path.join(source['ROC_TEST_DATA_PATH'], 'roc', 'film')
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'Using {data_test_path} to store test data')
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(self, command,
73
- base_url=None,
74
- test_data_dir=None,
75
- test_data_file='test_data.tar.gz',
76
- target_dir=None,
77
- overwrite=False,
78
- extract=True):
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 = '/'.join([base_url, command, test_data_file])
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'Downloading {test_data_url} in {test_data_dir} ...')
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(f'At least one of the following arguments missing: [username, password]!')
125
+ raise IOError(
126
+ "At least one of the following arguments missing: [username, password]!"
127
+ )
117
128
 
118
129
  else:
119
- logger.info(f'{test_data_path} already exists')
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'Extracting {test_data_path} ...')
124
- with tarfile.open(str(test_data_path), 'r:*') as tarball:
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'{test_data_path} is not a valid tarball!')
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(FilmTest.get_test_data_path(command), 'output')
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['pipeline']['output_path']
164
+ output_dir_path = conf["pipeline"]["output_path"]
149
165
  except KeyError:
150
- logger.debug('Variable pipeline.output_path not set in the config. file!')
166
+ logger.debug(
167
+ "Variable pipeline.output_path not set in the config. file!"
168
+ )
151
169
  else:
152
- if output_dir_path.startswith('$ROOT_DIRECTORY'):
153
- output_dir_path = output_dir_path.replace('$ROOT_DIRECTORY', settings.ROOT_DIRECTORY)
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'Using {output_dir_path} to store data produced during the test')
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, 'inputs')
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'{input_dir_path} not found')
191
+ logger.warning(f"{input_dir_path} not found")
172
192
  inputs = list()
173
193
  else:
174
- inputs = [item for item in os.listdir(input_dir_path)
175
- if os.path.isfile(os.path.join(input_dir_path, item))]
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'No input file found in {input_dir_path}')
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, 'expected_outputs')
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'{expected_output_dir_path} not found')
214
+ logger.warning(f"{expected_output_dir_path} not found")
192
215
  expected_outputs = list()
193
216
  else:
194
- expected_outputs = [item for item in os.listdir(expected_output_dir_path)
195
- if os.path.isfile(os.path.join(expected_output_dir_path, item))]
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'No input file found in {expected_output_dir_path}')
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(), 'data', 'spice_kernels')
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['environment'], os.environ]:
242
+ for source in [conf["environment"], os.environ]:
217
243
  try:
218
- spice_kernels_dir = os.path.join(source['SPICE_KERNEL_PATH'])
219
- except Exception:
220
- # logger.debug('Env. variable SPICE_KERNEL_PATH not set')
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(sub_dirs_cmp, path=os.path.join(path, parent)):
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('PIPELINE_CONFIG_FILE', None))
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(), 'roc', 'idb_release')
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['environment'], os.environ]:
287
+ for source in [conf["environment"], os.environ]:
260
288
  try:
261
- idb_dump_dir_path = os.path.join(source['IDB_INSTALL_DIR'])
262
- except Exception:
263
- # logger.debug('Env. variable IDB_INSTALL_DIR not set')
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'Using {idb_release_dir_path} to store RPW IDB source files')
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(test_class_instance,
274
- idb_version=None,
275
- idb_dump_file=None,
276
- user=os.environ.get('ROC_TEST_USER', 'roctest'),
277
- password=os.environ.get('ROC_TEST_PASSWORD', None),
278
- install_dir=None,
279
- log_level='ERROR'):
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('pop db upgrade heads -ll INFO')
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
- 'pop',
304
- '-ll',
333
+ "pop",
334
+ "-ll",
305
335
  log_level,
306
- 'idb',
307
- '--force',
308
- 'load_idb_dump',
309
- '--i',
336
+ "idb",
337
+ "--force",
338
+ "load_idb_dump",
339
+ "--i",
310
340
  install_dir,
311
- '-d',
341
+ "-d",
312
342
  idb_dump_file,
313
- '-a',
314
- user, password,
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
- 'pop',
321
- 'idb',
322
- 'install',
323
- '-i',
351
+ "pop",
352
+ "idb",
353
+ "install",
354
+ "-i",
324
355
  install_dir,
325
- '-s',
326
- 'PALISADE',
327
- '-v',
328
- '4.3.5_MEB_PFM',
329
- '--load',
330
- '-ll',
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
- 'pop',
337
- 'idb',
338
- 'install',
339
- '-i',
367
+ "pop",
368
+ "idb",
369
+ "install",
370
+ "-i",
340
371
  install_dir,
341
- '-s',
342
- 'MIB',
343
- '-v',
372
+ "-s",
373
+ "MIB",
374
+ "-v",
344
375
  idb_version,
345
- '--load',
346
- '-ll',
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('Missing input argument to load IDB!')
387
+ raise ValueError("Missing input argument to load IDB!")
357
388
 
358
389
  @staticmethod
359
- def load_l0(test_class_instance, l0_dir_path, idb_version,
360
- idb_source='MIB',
361
- pattern='solo_L0_rpw*.h5'):
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(list(glob.glob(os.path.join(kernels_dir, 'sclk', '*.tsc'))))[-1]
378
- except:
379
- raise FileNotFoundError('No SPICE SCLK kernel loaded!')
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'Use {sclk_file}')
419
+ logger.info(f"Use {sclk_file}")
382
420
  try:
383
- lsk_file = sorted(list(glob.glob(os.path.join(kernels_dir, 'lsk', '*.tls'))))[-1]
384
- except:
385
- raise FileNotFoundError('No SPICE LSK kernel loaded!')
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'Use {lsk_file}')
428
+ logger.info(f"Use {lsk_file}")
388
429
 
389
430
  # Inserting L0 data into the database
390
- cmd = ' '.join(['pop',
391
- '-ll INFO',
392
- 'dingo',
393
- f'--idb-version {idb_version}',
394
- f'--idb-source {idb_source}',
395
- f'--sclk {sclk_file}',
396
- f'--lsk {lsk_file}',
397
- 'l0_to_db',
398
- '-l0 ' + ' '.join(l0_files_path)])
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 = 'pop -ll INFO dingo l0_to_hfrtimelog -l0 ' + ' '.join(l0_files_path)
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))
@@ -14,7 +14,7 @@ import pytest
14
14
  import shutil
15
15
  import unittest.mock as mock
16
16
 
17
- from maser.tools.cdf.cdfcompare import cdf_compare
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 = 'l0_to_hk'
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
- #@pytest.mark.skip()
50
- @pytest.mark.parametrize('idb_source,idb_version', [
51
- ('MIB', '20200131'),
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 = 'l0_to_hk'
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'No input found in {test_data_dir}!')
68
- expected_output_dir_path, expected_outputs = FilmTest.get_expected_outputs(test_data_dir)
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'No expected output found in {test_data_dir}!')
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, 'output')
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(f'No SPICE kernel set found in {spice_kernels_dir}!')
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 = ' '.join(['pop',
83
- 'film',
84
- '--force',
85
- '--idb-version', idb_version,
86
- '--idb-source', idb_source,
87
- cmd,
88
- os.path.join(input_dir_path, inputs[0]),
89
- '--output-dir', output_dir_path,
90
- '-ll', 'INFO'])
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 = ['poppy.pop', 'roc.idb', 'roc.rpl', 'roc.rap', 'roc.dingo', 'roc.film']
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(Settings, 'configure',
98
- autospec=True,
99
- side_effect=self.mock_configure_settings(dictionary={'PLUGINS': plugin_list})):
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('.cdf'):
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
- 'File_ID',
122
- 'Generation_date',
123
- 'Pipeline_version',
124
- 'Pipeline_name',
125
- 'Software_version',
126
- 'IDB_version'
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(f'Differences between expected output and the command output: {pformat(result)}')
158
+ logger.error(
159
+ f"Differences between expected output and the command output: {pformat(result)}"
160
+ )
133
161
 
134
162
  assert result == {}