]> git.openstreetmap.org Git - nominatim.git/commitdiff
improve test coverage for reverse and debug output
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 20 Aug 2018 21:05:49 +0000 (23:05 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 20 Aug 2018 21:05:49 +0000 (23:05 +0200)
lib/DebugHtml.php
test/bdd/api/reverse/queries.feature
test/bdd/api/search/simple.feature
test/bdd/steps/queries.py

index a600fae58124edc6a441ad587bcbcf2e4652d67a..98da8794055c644e23fbb90ffdbbc6d3d5b45f8e 100644 (file)
@@ -155,6 +155,8 @@ class Debug
             }
         } elseif (is_object($mVar) && method_exists($mVar, 'debugInfo')) {
             Debug::outputVar($mVar->debugInfo(), $sPreNL);
+        } elseif (is_a($mVar, 'stdClass')) {
+            Debug::outputVar(json_decode(json_encode($mVar), true), $sPreNL);
         } else {
             Debug::outputSimpleVar($mVar);
         }
index 67e4676ccf6f67af7d771a2f4d3891cbb70b9e16..88f3bccbc34756e3b7b8284a541d14d323012864 100644 (file)
@@ -75,3 +75,19 @@ Feature: Reverse geocoding
          | 2    |
          | 3    |
          | 4    |
+
+    Scenario: When on a street, the closest interpolation is shown
+        When sending jsonv2 reverse coordinates -33.2309430210215,-54.38126470020989
+         | zoom |
+         | 18 |
+        Then results contain
+         | display_name |
+         | 1429, AndrĂ©s Areguati, Treinta y Tres, 33000, Uruguay |
+
+    Scenario: When on a street with zoom 18, the closest housenumber is returned
+        When sending jsonv2 reverse coordinates 53.551826690895226,9.885258475318201
+         | zoom |
+         | 18 |
+        Then result addresses contain
+         | house_number |
+         | 33 |
index 5cd80a83de36f77dbd7fe643f0262bd0780c49b2..ca441258784c2fde1f468883d77f768fb833b145 100644 (file)
@@ -233,6 +233,17 @@ Feature: Simple Tests
         When sending xml search query "Vaduz"
           | countrycodes |
           | pl,1,,invalid,undefined,%3Cb%3E,bo,, |
-       Then result header contains
+        Then result header contains
           | attr     | value |
           | more_url | .*&countrycodes=pl%2Cbo&.* |
+
+    Scenario Outline: Search with debug prints valid HTML
+        When sending html search query "<query>"
+          | extratags | addressdetails | namedetails | debug |
+          | 1         | 1              | 1           | 1     |
+        Then the result is valid html
+
+        Examples:
+          | query |
+          | 10, Alvierweg, 9490, Vaduz |
+          | Hamburg |
index fd13dd13b0f348c58dd725a6ff892b499e569de6..df34b5cc0696fc17d156a5500fb4047cb03b5b8f 100644 (file)
@@ -122,13 +122,17 @@ class SearchResponse(GenericResponse):
                                         options={'char-encoding' : 'utf8'})
         #eq_(len(errors), 0 , "Errors found in HTML document:\n%s" % errors)
 
+        self.result = []
         b = content.find('nominatim_results =')
         e = content.find('</script>')
-        content = content[b:e]
-        b = content.find('[')
-        e = content.rfind(']')
-
-        self.result = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(content[b:e+1])
+        if b >= 0 and e >= 0:
+            content = content[b:e]
+
+            b = content.find('[')
+            e = content.rfind(']')
+            if b >= 0 and e >= 0:
+                self.result = json.JSONDecoder(object_pairs_hook=OrderedDict)\
+                                  .decode(content[b:e+1])
 
     def parse_xml(self):
         et = ET.fromstring(self.page)