mirror of
https://github.com/ilri/csv-metadata-quality.git
synced 2024-11-24 23:00:17 +01:00
csv_metadata_quality/fix.py: fix logic error again
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
It seems there was another logic error raised by the test in pytest. With my real data, it was enough to check if the region column was None, but with my test I was explicitly setting the region to "" (an empty string). So to be really sure we should check if the string is not None *and* if its length is greater than 0.
This commit is contained in:
parent
40c3585bab
commit
0cf0bc97f0
@ -361,10 +361,11 @@ def countries_match_regions(row):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Add the missing regions back to the row, paying attention to whether
|
# Add the missing regions back to the row, paying attention to whether
|
||||||
# or not the row's regions are blank or not.
|
# or not the row's region column is None (aka null) or just an empty
|
||||||
if row[region_column_name] is not None:
|
# string (length would be 0).
|
||||||
row[region_column_name] = row[region_column_name] + "||" + "||".join(
|
if row[region_column_name] is not None and len(row[region_column_name]) > 0:
|
||||||
missing_regions
|
row[region_column_name] = (
|
||||||
|
row[region_column_name] + "||" + "||".join(missing_regions)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
row[region_column_name] = "||".join(missing_regions)
|
row[region_column_name] = "||".join(missing_regions)
|
||||||
|
Loading…
Reference in New Issue
Block a user