test(country-map): unit tests for build script transforms (18 cases)

Covers the pure-Python helpers and YAML-applied transforms that the
build pipeline relies on. Subprocess calls (mapshaper, NE download)
are not exercised — those are integration concerns covered by the
regen workflow itself.

Test categories:
- _matches (4 tests): scalar equality, AND'd conditions, `in: [...]`
  list-membership matcher, missing property
- _bbox_center (2 tests): unit square, offset square
- _translate_and_scale (4 tests): pure translate, scale-around-centroid,
  combined transform, multipolygon handling
- _translate_and_scale_with_pivot (1 test): shared pivot preserves
  relative positions of grouped features (the Paris-petite-couronne case)
- _drop_parts (2 tests): drops specified indices, polygon unchanged
- _bbox_contains (2 tests): inside-bbox, outside-bbox-west
- apply_name_overrides (1 test): applies only to matching features,
  respects match conditions across countries (FRA "Seien" vs GBR "Seien"
  don't collide)
- apply_flying_islands (2 tests): repositions matched features,
  drop_outside_bbox guarded to Admin 1 only (the bug we fixed earlier)

Wired into the regen workflow as a step that runs BEFORE the build,
so a broken transform fails CI before producing potentially-bad output
files.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Evan Rusackas
2026-05-12 17:37:27 -07:00
parent cd85b2dc99
commit 8a06bbac1e
2 changed files with 281 additions and 0 deletions

View File

@@ -40,6 +40,11 @@ jobs:
python -m pip install --upgrade pip
pip install pyyaml
- name: Run unit tests for build transforms
run: |
cd superset-frontend/plugins/plugin-chart-country-map/scripts
python -m unittest test_build -v
- name: Run build pipeline
run: |
cd superset-frontend/plugins/plugin-chart-country-map/scripts