Skip to content

Commit

Permalink
Fix error when a changeset has an empty host value
Browse files Browse the repository at this point in the history
  • Loading branch information
willemarcel committed Feb 23, 2024
1 parent e7f26e0 commit 055b62e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 4 additions & 1 deletion osmcha/changeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,8 @@ def get_dict(self):
ch_dict.pop(key)

for field in FIELDS_TO_REMOVE:
ch_dict.pop(field)
try:
ch_dict.pop(field)
except KeyError:
pass
return ch_dict
22 changes: 21 additions & 1 deletion tests/test_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ def test_analyse_verify_editor_id_osm():
assert ch.suspicion_reasons == []



def test_verify_editor_id_is_known_instance():
"""Test if iD is not a powerfull_editor and if 'Unknown iD instance' is added
to suspicion_reasons.
Expand Down Expand Up @@ -904,6 +903,27 @@ def test_changeset_with_warning_tag_invalid_format():
assert not changeset.is_suspect


def get_dict_doesnt_fail_with_empty_host_value():
ch_dict = {
'created_by': 'iD',
'created_at': '2019-04-25T18:08:46Z',
'host': '',
'comment': 'add pois',
'id': '1',
'user': 'JustTest',
'uid': '123123',
'bbox': Polygon([
(-71.0646843, 44.2371354), (-71.0048652, 44.2371354),
(-71.0048652, 44.2430624), (-71.0646843, 44.2430624),
(-71.0646843, 44.2371354)
])
}
changeset = Analyse(ch_dict)
changeset.full_analysis()
processed_dict = changeset.get_dict()
assert 'host' not in processed_dict.keys()


def test_enabled_warnings():
warnings = Warnings()
assert warnings.get_non_exact_match_warnings() == [
Expand Down

0 comments on commit 055b62e

Please sign in to comment.