Skip to content
Snippets Groups Projects

[Tests] Validate metadata for retrieved constants before validating the corrected files

Merged Karim Ahmed requested to merge test/check_retrieved_constants into master
1 unresolved thread
2 files
+ 12
19
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -14,6 +14,7 @@ import h5py
import numpy as np
import pytest
import yaml
from deepdiff import DeepDiff
import xfel_calibrate.calibrate as calibrate
@@ -258,21 +259,10 @@ def slurm_watcher(test_key: str, std_out: str):
LOGGER.info(f"{test_key}'s jobs were COMPLETED")
def compare_metadata_ccvs(test, reference, tested_key):
def load_yaml(file_path):
with open(file_path, 'r') as file:
return yaml.safe_load(file)
def load_yaml(file_path):
with open(file_path, 'r') as file:
return yaml.safe_load(file)
# Load the relevant section from both files
ccvs_test = load_yaml(test).get(tested_key, {})
ccvs_reference = load_yaml(reference).get(tested_key, {})
# Compare the content directly
if ccvs_test == ccvs_reference:
return True
else:
return False
@pytest.mark.manual_run
@pytest.mark.parametrize(
@@ -379,11 +369,13 @@ def test_xfel_calibrate(
if cal_type.lower() == "correct":
# For corrections validate calibration constants
metadata_file = f"calibration_metadata_{cal_conf['karabo-id']}.yml"
assert compare_metadata_ccvs(
out_folder / metadata_file,
reference_folder / metadata_file,
"retrieved-constants",
), "Found difference in the metadata for the retrieved Constants."
# Load the relevant section from both files
ccvs_test = load_yaml(
out_folder / metadata_file)["retrieved-constants"]
ccvs_reference = load_yaml(
reference_folder / metadata_file)["retrieved-constants"]
ccvs_diff = DeepDiff(ccvs_test, ccvs_reference, ignore_order=True)
assert ccvs_diff == {}, "Found difference in the metadata for the retrieved Constants." # noqa
LOGGER.info("Retrieved CCVs validated.")
# Stop tests at this point, if desired.
Loading