From 1cadef58d1b584706b87b1e14c41e205dc22fe1f Mon Sep 17 00:00:00 2001 From: Michael Richey Date: Wed, 30 Sep 2026 11:17:22 -0400 Subject: [PATCH] fix(integration): clear caplog before diffs assertions and handle non-recurrence downtime dates Two fixes for integration test failures: 1. Clear caplog between import and diffs phases in test_resource_import and test_resource_import_per_file. Import-phase skip messages (e.g. 'Downtime is canceled') were leaking into the diffs caplog assertion, causing false failures when the diffs command itself produced no skip-related output. 2. Extend RECURRENCE_START_ATTR_PATH_RE to also match schedule.start (not just schedule.recurrences[N].start). Downtimes created without recurrences use schedule.start directly, and the date operator was not normalizing timezone format differences (+00:00 vs Z) for these, causing false diffs after update+sync. --- datadog_sync/utils/resource_utils.py | 2 +- tests/integration/helpers.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/datadog_sync/utils/resource_utils.py b/datadog_sync/utils/resource_utils.py index 0feae3364..0ce84b182 100644 --- a/datadog_sync/utils/resource_utils.py +++ b/datadog_sync/utils/resource_utils.py @@ -148,7 +148,7 @@ def give_up_diffing(self, level, diff_instance) -> bool: return False -RECURRENCE_START_ATTR_PATH_RE = r"root\['attributes'\]\['schedule'\]\['recurrences'\]\[[0-9]+\]\['start'\]" +RECURRENCE_START_ATTR_PATH_RE = r"root\['attributes'\]\['schedule'\](?:\['recurrences'\]\[[0-9]+\])?\['start'\]" class DowntimeSchedulesDateOperator(BaseOperator): diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index 918615e1a..cc92946fa 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -133,6 +133,10 @@ def test_resource_import(self, runner, caplog): source_resources, _ = open_resources(self.resource_type) assert len(source_resources) > 0 + # Clear caplog so import-phase skip messages don't leak into the diffs + # assertion below (e.g. canceled downtimes skipped during import). + caplog.clear() + # Disable skipping on resource connection failure # From stdout, count the number of resources to be added and ensure they match the import len() diff_cmd = [ @@ -414,6 +418,10 @@ def test_resource_import_per_file(self, runner, caplog): ":", "." ), f"Resource with ID {resource_id} should have a file with {file_id}" + # Clear caplog so import-phase skip messages don't leak into the diffs + # assertion below (e.g. canceled downtimes skipped during import). + caplog.clear() + # Run diffs to ensure everything is recognized properly ret = runner.invoke( cli,