]> git.openstreetmap.org Git - nominatim.git/commitdiff
add remaining reverse tests
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 22 Dec 2016 21:28:23 +0000 (22:28 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 30 Dec 2016 21:58:58 +0000 (22:58 +0100)
test/bdd/api/reverse/params.feature [new file with mode: 0644]
test/bdd/api/reverse/queries.feature [new file with mode: 0644]
test/bdd/api/reverse/simple.feature
test/bdd/db/update/interpolation.feature
test/bdd/steps/queries.py

diff --git a/test/bdd/api/reverse/params.feature b/test/bdd/api/reverse/params.feature
new file mode 100644 (file)
index 0000000..0d35cdc
--- /dev/null
@@ -0,0 +1,102 @@
+@APIDB
+Feature: Parameters for Reverse API
+    Testing diferent parameter options for reverse API.
+
+    Scenario Outline: Reverse-geocoding without address
+        When sending <format> reverse coordinates 53.603,10.041
+          | addressdetails |
+          | 0 |
+        Then exactly 1 result is returned
+        And result has not attributes address
+
+    Examples:
+      | format |
+      | json |
+      | jsonv2 |
+      | xml |
+
+    Scenario Outline: Reverse Geocoding with extratags
+        When sending <format> reverse coordinates 10.776234290950017,106.70425325632095
+          | extratags |
+          | 1 |
+        Then result 0 has attributes extratags
+
+    Examples:
+        | format |
+        | xml |
+        | json |
+        | jsonv2 |
+
+    Scenario Outline: Reverse Geocoding with namedetails
+        When sending <format> reverse coordinates 10.776455623137625,106.70175343751907
+          | namedetails |
+          | 1 |
+        Then result 0 has attributes namedetails
+
+    Examples:
+        | format |
+        | xml |
+        | json |
+        | jsonv2 |
+
+    Scenario Outline: Reverse Geocoding contains TEXT geometry
+        When sending <format> reverse coordinates 47.165989816710066,9.515774846076965
+          | polygon_text |
+          | 1 |
+        Then result 0 has attributes <response_attribute>
+
+    Examples:
+        | format   | response_attribute |
+        | xml      | geotext |
+        | json     | geotext |
+        | jsonv2   | geotext |
+
+    Scenario Outline: Reverse Geocoding contains polygon-as-points geometry
+        When sending <format> reverse coordinates 47.165989816710066,9.515774846076965
+          | polygon |
+          | 1 |
+        Then result 0 has not attributes <response_attribute>
+
+    Examples:
+        | format   | response_attribute |
+        | xml      | polygonpoints |
+        | json     | polygonpoints |
+        | jsonv2   | polygonpoints |
+
+    Scenario Outline: Reverse Geocoding contains SVG geometry
+        When sending <format> reverse coordinates 47.165989816710066,9.515774846076965
+          | polygon_svg |
+          | 1 |
+        Then result 0 has attributes <response_attribute>
+
+    Examples:
+        | format   | response_attribute |
+        | xml      | geosvg |
+        | json     | svg |
+        | jsonv2   | svg |
+
+    Scenario Outline: Reverse Geocoding contains KML geometry
+        When sending <format> reverse coordinates 47.165989816710066,9.515774846076965
+          | polygon_kml |
+          | 1 |
+        Then result 0 has attributes <response_attribute>
+
+    Examples:
+        | format   | response_attribute |
+        | xml      | geokml |
+        | json     | geokml |
+        | jsonv2   | geokml |
+
+    Scenario Outline: Reverse Geocoding contains GEOJSON geometry
+        When sending <format> reverse coordinates 47.165989816710066,9.515774846076965
+          | polygon_geojson |
+          | 1 |
+        Then result 0 has attributes <response_attribute>
+
+    Examples:
+        | format   | response_attribute |
+        | xml      | geojson |
+        | json     | geojson |
+        | jsonv2   | geojson |
+
+
diff --git a/test/bdd/api/reverse/queries.feature b/test/bdd/api/reverse/queries.feature
new file mode 100644 (file)
index 0000000..e1d089b
--- /dev/null
@@ -0,0 +1,25 @@
+@APIDB
+Feature: Reverse geocoding
+    Testing the reverse function
+
+    @Tiger
+    Scenario: TIGER house number
+        When sending jsonv2 reverse coordinates 45.3345,-97.5214
+        Then results contain
+          | osm_type | category | type |
+          | way      | place    | house |
+        And result addresses contain
+          | house_number | road            | postcode | country_code |
+          | 906          | West 1st Street | 57274    | us |
+
+    @Tiger
+    Scenario: No TIGER house number for zoom < 18
+        When sending jsonv2 reverse coordinates 45.3345,-97.5214
+          | zoom |
+          | 17 |
+        Then results contain
+          | osm_type | category |
+          | way      | highway  |
+        And result addresses contain
+          | road            | postcode | country_code |
+          | West 1st Street | 57274    | us |
index b14d9e86df5e3d92893944fede5586877af3ab7f..2b4847364592e35d845b064854b08ab67bdcc446 100644 (file)
@@ -67,17 +67,17 @@ Feature: Simple Reverse Tests
       | json |
       | jsonv2 |
 
-    Scenario Outline: Reverse-geocoding without address
-        When sending <format> reverse coordinates 53.603,10.041
-          | addressdetails |
-          | 0 |
-        Then exactly 1 result is returned
+    @wip
+    Scenario Outline: Boundingbox is returned
+        When sending <format> reverse coordinates 14.62,108.1
+          | zoom |
+          | 4 |
+        Then result has bounding box in 9,20,102,113
 
     Examples:
       | format |
       | json |
       | jsonv2 |
-      | html |
       | xml |
 
     Scenario Outline: Reverse-geocoding with zoom
index a9e56cce34bd6f714face6a54e228351235edcb7..7dd5bdc0de99580fc5febd5768c176d7c84d0b43 100644 (file)
@@ -2,6 +2,31 @@
 Feature: Update of address interpolations
     Test the interpolated address are updated correctly
 
+    @wip
+    Scenario: new interpolation added to existing street
+      Given the scene parallel-road
+      And the places
+          | osm | class   | type         | name         | geometry |
+          | W2  | highway | unclassified | Sun Way      | :w-north |
+          | W3  | highway | unclassified | Cloud Street | :w-south |
+      And the ways
+          | id  | nodes |
+          | 10  | 1,100,101,102,2 |
+      When importing
+      Then W10 expands to no interpolation
+      When updating places
+          | osm | class | type  | housenr | geometry |
+          | N1  | place | house | 2       | :n-middle-w |
+          | N2  | place | house | 6       | :n-middle-e |
+          | W10 | place | houses | even   | :w-middle |
+      Then placex contains
+          | object | parent_place_id |
+          | N1     | W2 |
+          | N2     | W2 |
+      And W10 expands to interpolation
+          | parent_place_id | start | end |
+          | W2              | 2     | 6 |
+
     Scenario: addr:street added to interpolation
       Given the scene parallel-road
       And the places
index 81dc0ccdbc4182311a6f4cc243ce2d8d6af7365c..175a85ae7141aa84032df194b5bf0f0bacb62995 100644 (file)
@@ -54,8 +54,40 @@ def compare(operator, op1, op2):
     else:
         raise Exception("unknown operator '%s'" % operator)
 
+class GenericResponse(object):
 
-class SearchResponse(object):
+    def match_row(self, row):
+        if 'ID' in row.headings:
+            todo = [int(row['ID'])]
+        else:
+            todo = range(len(self.result))
+
+        for i in todo:
+            res = self.result[i]
+            for h in row.headings:
+                if h == 'ID':
+                    pass
+                elif h == 'osm':
+                    assert_equal(res['osm_type'], row[h][0])
+                    assert_equal(res['osm_id'], row[h][1:])
+                elif h == 'centroid':
+                    x, y = row[h].split(' ')
+                    assert_almost_equal(float(y), float(res['lat']))
+                    assert_almost_equal(float(x), float(res['lon']))
+                elif row[h].startswith("^"):
+                    assert_in(h, res)
+                    assert_is_not_none(re.fullmatch(row[h], res[h]),
+                                       "attribute '%s': expected: '%s', got '%s'"
+                                          % (h, row[h], res[h]))
+                else:
+                    assert_in(h, res)
+                    assert_equal(str(res[h]), str(row[h]))
+
+    def property_list(self, prop):
+        return [ x[prop] for x in self.result ]
+
+
+class SearchResponse(GenericResponse):
 
     def __init__(self, page, fmt='json', errorcode=200):
         self.page = page
@@ -117,38 +149,8 @@ class SearchResponse(object):
                 self.result[-1]['address'] = address
 
 
-    def match_row(self, row):
-        if 'ID' in row.headings:
-            todo = [int(row['ID'])]
-        else:
-            todo = range(len(self.result))
 
-        for i in todo:
-            res = self.result[i]
-            for h in row.headings:
-                if h == 'ID':
-                    pass
-                elif h == 'osm':
-                    assert_equal(res['osm_type'], row[h][0])
-                    assert_equal(res['osm_id'], row[h][1:])
-                elif h == 'centroid':
-                    x, y = row[h].split(' ')
-                    assert_almost_equal(float(y), float(res['lat']))
-                    assert_almost_equal(float(x), float(res['lon']))
-                elif row[h].startswith("^"):
-                    assert_in(h, res)
-                    assert_is_not_none(re.fullmatch(row[h], res[h]),
-                                       "attribute '%s': expected: '%s', got '%s'"
-                                          % (h, row[h], res[h]))
-                else:
-                    assert_in(h, res)
-                    assert_equal(str(res[h]), str(row[h]))
-
-    def property_list(self, prop):
-        return [ x[prop] for x in self.result ]
-
-
-class ReverseResponse(object):
+class ReverseResponse(GenericResponse):
 
     def __init__(self, page, fmt='json', errorcode=200):
         self.page = page
@@ -212,7 +214,6 @@ class ReverseResponse(object):
                         "Unknown XML tag %s on page: %s" % (child.tag, self.page)
 
 
-
 @when(u'searching for "(?P<query>.*)"(?P<dups> with dups)?')
 def query_cmd(context, query, dups):
     """ Query directly via PHP script.