Commit ae32d7b7 authored by David Foucher's avatar David Foucher

Merge branch '309-bug-department-975' into 'master'

Fix 309 bug department 975

See merge request ybon/trefle!94
parents 5bb6ecac 8d54674c
......@@ -89,6 +89,7 @@ def test_fold_name(input, expected):
("20", "94"), # When consuming postode
("971", "01"), # Guadeloupe
("972", "02"), # Martinique
("975", None), # no region for saint-pierre
("blah", False),
],
)
......@@ -98,8 +99,12 @@ def test_insee_departement_to_region(input, expected):
insee_departement_to_region(context, "departement", "region")
assert context["region"] == expected
else:
with pytest.raises(DataError):
if expected is None:
insee_departement_to_region(context, "departement", "region")
assert "region" not in context
else:
with pytest.raises(DataError):
insee_departement_to_region(context, "departement", "region")
def test_insee_departement_to_region_with_alias(patch_schema):
......
......@@ -111,6 +111,9 @@ def insee_departement_to_region(context, from_key, to_key):
dep = context[from_key]
except (KeyError, NoDataError):
return
if dep in {'975', '977', '978', '984', '986'}:
# pas de région pour ces codes départements
return
if dep not in DEP_TO_REG:
raise DataError(f"Valeur invalide: `{context[from_key]}`", from_key)
context[to_key] = DEP_TO_REG[dep]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment