Skip to content

Commit 411c8ad

Browse files
test: unify the adaptive-mapping collision namespace per review — tier fills and texts share the [fill=] selector space; entity_fill and cluster label included
1 parent 0fbf5a4 commit 411c8ad

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

tests/integration/test_diagram_style.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,23 @@ def test_theme_text_contrast_meets_aa():
175175

176176

177177
def test_adaptive_mapping_is_collision_free():
178-
"""Every light color maps to exactly one dark counterpart per attribute (#1532 invariant)."""
178+
"""Every light color maps to exactly one dark counterpart per attribute (#1532 invariant).
179+
180+
One unified namespace per attribute kind: tier fills and tier texts both emit
181+
[fill=...] selectors in the adaptive block, so they must not collide with each
182+
other either; entity_fill and the schema-cluster label are fill rules too.
183+
"""
179184
light, dark = dj.diagram._DIAGRAM_THEMES["light"], dj.diagram._DIAGRAM_THEMES["dark"]
185+
mapping = {}
180186
for idx, kind in ((0, "fill"), (1, "stroke"), (2, "fill")):
181-
mapping = {}
182187
for tier in light["palette"]:
183188
lv, dv = light["palette"][tier][idx].lower(), dark["palette"][tier][idx]
184189
assert mapping.setdefault((kind, lv), dv) == dv, f"collision on {kind} {lv}"
185-
strokes = {}
186-
for lv, dv in [
187-
(light["edge"].lower(), dark["edge"]),
188-
(light["edge_renamed"].lower(), dark["edge_renamed"]),
189-
(light["schema_cluster"][0].lower(), dark["schema_cluster"][0]),
190+
for lkey, dkey, kind in [
191+
(light["edge"], dark["edge"], "stroke"),
192+
(light["edge_renamed"], dark["edge_renamed"], "stroke"),
193+
(light["schema_cluster"][0], dark["schema_cluster"][0], "stroke"),
194+
(light["entity_fill"], dark["entity_fill"], "fill"),
195+
(light["schema_cluster"][1], dark["schema_cluster"][1], "fill"),
190196
]:
191-
assert strokes.setdefault(lv, dv) == dv, f"stroke collision on {lv}"
197+
assert mapping.setdefault((kind, lkey.lower()), dkey) == dkey, f"collision on {kind} {lkey}"

0 commit comments

Comments
 (0)