1717
1818from typing import Dict , List , Optional
1919
20- import pytest
21-
2220from diffsync import Adapter , DiffSyncModel
2321from diffsync .enum import DiffSyncFlags
2422
25-
2623# ---------------------------------------------------------------------------
2724# Models and adapters used across this test module
2825# ---------------------------------------------------------------------------
2926
27+
3028class _Site (DiffSyncModel ):
3129 _modelname = "site"
3230 _identifiers = ("name" ,)
@@ -97,6 +95,7 @@ def _make_adapter_pair():
9795# model_types scoping
9896# ---------------------------------------------------------------------------
9997
98+
10099def test_diff_with_model_types_restricts_to_site_only ():
101100 """Passing model_types={'site'} should exclude child device elements from the diff."""
102101 src , dst = _make_adapter_pair ()
@@ -133,6 +132,7 @@ def test_sync_with_model_types_does_not_touch_excluded_types():
133132# sync_attrs / exclude_attrs
134133# ---------------------------------------------------------------------------
135134
135+
136136def test_sync_attrs_limits_diff_to_whitelisted_attributes ():
137137 """Only the attributes named in sync_attrs should appear in the diff."""
138138 src , dst = _make_adapter_pair ()
@@ -179,6 +179,7 @@ def test_sync_attrs_and_exclude_attrs_applied_together():
179179# filters (query predicates)
180180# ---------------------------------------------------------------------------
181181
182+
182183def test_filters_include_matching_objects ():
183184 """Objects whose predicate returns True should be included in the diff."""
184185 src , dst = _make_adapter_pair ()
@@ -190,8 +191,8 @@ def test_filters_include_matching_objects():
190191 if device_el .type == "device" :
191192 device_names .add (device_el .name )
192193
193- assert "device1" in device_names # spine in source
194- assert "device3" in device_names # spine in source
194+ assert "device1" in device_names # spine in source
195+ assert "device3" in device_names # spine in source
195196 assert "device2" not in device_names # leaf in source, filtered out
196197
197198
@@ -222,6 +223,7 @@ def test_filters_do_not_affect_unfiltered_types():
222223# sync_filter callback
223224# ---------------------------------------------------------------------------
224225
226+
225227def test_sync_filter_blocks_delete_operations ():
226228 """A sync_filter that rejects deletes should preserve objects that only exist in the destination."""
227229 src , dst = _make_adapter_pair ()
@@ -280,6 +282,7 @@ def test_sync_filter_blocks_by_model_type():
280282# sync_complete operations summary
281283# ---------------------------------------------------------------------------
282284
285+
283286class _TrackingAdapter (_SimpleAdapter ):
284287 """Adapter that captures the operations dict passed to sync_complete."""
285288
@@ -354,6 +357,7 @@ def sync_complete(self, source, diff, flags=DiffSyncFlags.NONE, logger=None):
354357# concurrent sync
355358# ---------------------------------------------------------------------------
356359
360+
357361def test_concurrent_sync_matches_serial_sync ():
358362 """Syncing with concurrent=True should produce the same result as a serial sync."""
359363 src , dst_serial = _make_adapter_pair ()
@@ -377,6 +381,7 @@ def test_sync_defaults_to_serial():
377381# Combinations of multiple parameters
378382# ---------------------------------------------------------------------------
379383
384+
380385def test_diff_filter_then_sync_with_sync_filter ():
381386 """A pre-filtered Diff combined with a sync_filter should respect both layers."""
382387 src , dst = _make_adapter_pair ()
0 commit comments