Skip to content

Commit 3e93bb6

Browse files
committed
fix(well-inventory): treat whitespace-only lexicon values as blank
1 parent 1460d4f commit 3e93bb6

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

schemas/well_inventory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ def email_validator_function(email_str):
125125

126126
def flexible_lexicon_validator(enum_cls):
127127
def validator(v):
128-
if v is None or v == "":
128+
if v is None:
129+
return None
130+
if isinstance(v, str) and v.strip() == "":
129131
return None
130132
if isinstance(v, enum_cls):
131133
return v

tests/test_well_inventory.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,14 @@ def test_blank_well_status_is_treated_as_none(self):
12581258

12591259
assert model.well_status is None
12601260

1261+
def test_whitespace_only_well_status_is_treated_as_none(self):
1262+
row = _minimal_valid_well_inventory_row()
1263+
row["well_hole_status"] = " "
1264+
1265+
model = WellInventoryRow(**row)
1266+
1267+
assert model.well_status is None
1268+
12611269
def test_canonical_name_wins_when_alias_and_canonical_present(self):
12621270
row = _minimal_valid_well_inventory_row()
12631271
row["well_status"] = "Abandoned"

0 commit comments

Comments
 (0)