From 793f9817f1b6dc953aa66fa0020a3084d48eac04 Mon Sep 17 00:00:00 2001 From: Container Date: Thu, 22 Oct 2026 15:22:20 +0000 Subject: [PATCH 1/2] Use current custom metadata key in modify dates rules The modify dates profile still used the old delete_custom_metadata key, which is silently ignored by the dicom rules model. Use custom_metadata_action, matching the base rules. --- imagedephi/modify_dates_rules.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagedephi/modify_dates_rules.yaml b/imagedephi/modify_dates_rules.yaml index a76328e2..cdfdc3cc 100644 --- a/imagedephi/modify_dates_rules.yaml +++ b/imagedephi/modify_dates_rules.yaml @@ -824,7 +824,7 @@ dicom: action: delete default: action: keep - delete_custom_metadata: true + custom_metadata_action: delete metadata: AccessionNumber: action: empty From abf5cfc3d694bedc8e0c50e4445829367d3bff53 Mon Sep 17 00:00:00 2001 From: Container Date: Thu, 22 Oct 2026 15:24:48 +0000 Subject: [PATCH 2/2] Add test that the modify dates profile matches the base profile The modify dates rules are a full copy of the base rules rather than an overlay, so rules added to the base profile must be mirrored there. The test checks that both profiles have the same structure and actions, other than actions changed to modify_date. --- imagedephi/modify_dates_rules.yaml | 2 ++ tests/test_profile_rules.py | 34 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/test_profile_rules.py diff --git a/imagedephi/modify_dates_rules.yaml b/imagedephi/modify_dates_rules.yaml index cdfdc3cc..09bcf651 100644 --- a/imagedephi/modify_dates_rules.yaml +++ b/imagedephi/modify_dates_rules.yaml @@ -810,6 +810,8 @@ svs: action: keep CalibrationAverageRed: action: keep + Calibration Point Source: + action: keep ScannerType: action: delete SessionMode: diff --git a/tests/test_profile_rules.py b/tests/test_profile_rules.py new file mode 100644 index 00000000..248abbf7 --- /dev/null +++ b/tests/test_profile_rules.py @@ -0,0 +1,34 @@ +import importlib.resources +from typing import Any + +import yaml + + +def _load_profile(file_name: str) -> dict: + with (importlib.resources.files("imagedephi") / file_name).open() as stream: + return yaml.safe_load(stream) + + +def _profile_differences(base: Any, other: Any, path: str = "") -> list[str]: + """List places where the modify dates profile deviates from the base profile.""" + if isinstance(base, dict) and isinstance(other, dict): + differences = [f"{path}/{key}: only in base rules" for key in base.keys() - other.keys()] + differences += [ + f"{path}/{key}: only in modify dates rules" for key in other.keys() - base.keys() + ] + for key in base.keys() & other.keys(): + differences += _profile_differences(base[key], other[key], f"{path}/{key}") + return differences + if base == other or (path.endswith("/action") and other == "modify_date"): + return [] + return [f"{path}: {base!r} != {other!r}"] + + +def test_modify_dates_profile_matches_base_profile(): + base = _load_profile("base_rules.yaml") + modify_dates = _load_profile("modify_dates_rules.yaml") + for key in ("name", "description"): + base.pop(key) + modify_dates.pop(key) + + assert sorted(_profile_differences(base, modify_dates)) == []