+
+
+def test_search_details_grouped_hierarchy():
+ search = napi.DetailedResult(napi.SourceTable.PLACEX,
+ ('place', 'thing'),
+ napi.Point(1.0, 2.0),
+ parented_rows =
+ [napi.AddressLine(place_id=3498,
+ osm_object=('R', 442),
+ category=('bnd', 'note'),
+ names={'name': 'Trespass'},
+ extratags={'access': 'no',
+ 'place_type': 'spec'},
+ admin_level=4,
+ fromarea=True,
+ isaddress=True,
+ rank_address=10,
+ distance=0.034)
+ ])
+
+ result = v1_format.format_result(search, 'json', {'group_hierarchy': True})
+ js = json.loads(result)
+
+ assert js['hierarchy'] == {'note': [{'localname': 'Trespass',
+ 'place_id': 3498,
+ 'osm_id': 442,
+ 'osm_type': 'R',
+ 'place_type': 'spec',
+ 'class': 'bnd',
+ 'type': 'note',
+ 'admin_level': 4,
+ 'rank_address': 10,
+ 'distance': 0.034,
+ 'isaddress': True}]}
+
+
+def test_search_details_keywords_name():
+ search = napi.DetailedResult(napi.SourceTable.PLACEX,
+ ('place', 'thing'),
+ napi.Point(1.0, 2.0),
+ name_keywords=[
+ napi.WordInfo(23, 'foo', 'mefoo'),
+ napi.WordInfo(24, 'foo', 'bafoo')])
+
+ result = v1_format.format_result(search, 'json', {'keywords': True})
+ js = json.loads(result)
+
+ assert js['keywords'] == {'name': [{'id': 23, 'token': 'foo'},
+ {'id': 24, 'token': 'foo'}],
+ 'address': []}
+
+
+def test_search_details_keywords_address():
+ search = napi.DetailedResult(napi.SourceTable.PLACEX,
+ ('place', 'thing'),
+ napi.Point(1.0, 2.0),
+ address_keywords=[
+ napi.WordInfo(23, 'foo', 'mefoo'),
+ napi.WordInfo(24, 'foo', 'bafoo')])
+
+ result = v1_format.format_result(search, 'json', {'keywords': True})
+ js = json.loads(result)
+
+ assert js['keywords'] == {'address': [{'id': 23, 'token': 'foo'},
+ {'id': 24, 'token': 'foo'}],
+ 'name': []}
+