Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flag changesets with the tag 'review_requested=yes' #24

Merged
merged 1 commit into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions osmcha/changeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def __init__(self, changeset, create_threshold=200, modify_threshold=200,
suspect_words=WORDS['common'] + WORDS['sources'],
illegal_sources=WORDS['sources'], excluded_words=WORDS['exclude']):
if type(changeset) in [int, str]:
changeset_details = changeset_info(get_metadata(changeset))
self.set_fields(changeset_details)
self.set_fields(changeset_info(get_metadata(changeset)))
elif type(changeset) == dict:
self.set_fields(changeset)
else:
Expand All @@ -200,6 +199,7 @@ def set_fields(self, changeset):
self.user = changeset.get('user')
self.uid = changeset.get('uid')
self.editor = changeset.get('created_by', None)
self.review_requested = changeset.get('review_requested', False)
self.host = changeset.get('host', 'Not reported')
self.bbox = changeset.get('bbox').wkt
self.comment = changeset.get('comment', 'Not reported')
Expand All @@ -224,6 +224,9 @@ def full_analysis(self):
self.verify_words()
self.verify_user()

if self.review_requested == 'yes':
self.label_suspicious('Review requested')

def verify_user(self):
"""Verify if the changeset was made by a inexperienced mapper (anyone
with less than 5 edits) or by a user that was blocked more than once.
Expand Down Expand Up @@ -332,7 +335,7 @@ def get_dict(self):
fields_to_remove = [
'create_threshold', 'modify_threshold', 'illegal_sources',
'delete_threshold', 'percentage', 'top_threshold', 'suspect_words',
'excluded_words', 'host'
'excluded_words', 'host', 'review_requested',
]
for field in fields_to_remove:
ch_dict.pop(field)
Expand Down
21 changes: 21 additions & 0 deletions tests/test_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,24 @@ def test_changeset_by_old_mapper_with_special_character_username():
changeset.full_analysis()
assert 'New mapper' not in changeset.suspicion_reasons
assert not changeset.is_suspect


def test_changeset_with_review_requested():
ch_dict = {
'created_by': 'Potlatch 2',
'created_at': '2015-04-25T18:08:46Z',
'comment': 'add pois',
'id': '1',
'user': 'JustTest',
'uid': '123123',
'review_requested': 'yes',
'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()
assert 'Review requested' in changeset.suspicion_reasons
assert changeset.is_suspect