From be58b929f2131d2c6aaa8b5c702a574c3812371b Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 12 Jul 2018 22:00:18 +0200 Subject: [PATCH] add tests for geocodejson and fix syntax errors --- lib/template/address-geocodejson.php | 2 +- lib/template/search-geocodejson.php | 4 ++-- test/bdd/api/reverse/simple.feature | 4 ++++ test/bdd/api/search/simple.feature | 4 ++++ test/bdd/steps/queries.py | 6 ++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/template/address-geocodejson.php b/lib/template/address-geocodejson.php index 480a4f9e..68fae7d1 100644 --- a/lib/template/address-geocodejson.php +++ b/lib/template/address-geocodejson.php @@ -76,6 +76,6 @@ if (empty($aPlace)) { 'licence' => 'ODbL', 'query' => $sQuery ), - 'features' => $aFilteredPlaces + 'features' => [$aFilteredPlaces] )); } diff --git a/lib/template/search-geocodejson.php b/lib/template/search-geocodejson.php index f3c577d9..29bfe0bf 100644 --- a/lib/template/search-geocodejson.php +++ b/lib/template/search-geocodejson.php @@ -9,8 +9,8 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) { ) ); - if (isset($aPlace['place_id'])) $aPlace['properties']['geocoding']['place_id'] = $aPointDetails['place_id']; - $sOSMType = formatOSMType($aPlace['osm_type']); + if (isset($aPointDetails['place_id'])) $aPlace['properties']['geocoding']['place_id'] = $aPointDetails['place_id']; + $sOSMType = formatOSMType($aPointDetails['osm_type']); if ($sOSMType) { $aPlace['properties']['geocoding']['osm_type'] = $sOSMType; $aPlace['properties']['geocoding']['osm_id'] = $aPointDetails['osm_id']; diff --git a/test/bdd/api/reverse/simple.feature b/test/bdd/api/reverse/simple.feature index 115b0fd3..ccd0becd 100644 --- a/test/bdd/api/reverse/simple.feature +++ b/test/bdd/api/reverse/simple.feature @@ -48,6 +48,10 @@ Feature: Simple Reverse Tests | param | value | | | | Then the result is valid geojson + When sending geocodejson reverse coordinates 53.603,10.041 + | param | value | + | | | + Then the result is valid geocodejson Examples: | parameter | value | diff --git a/test/bdd/api/search/simple.feature b/test/bdd/api/search/simple.feature index 06c24a2e..5cd80a83 100644 --- a/test/bdd/api/search/simple.feature +++ b/test/bdd/api/search/simple.feature @@ -27,6 +27,10 @@ Feature: Simple Tests | param | value | | | | Then at least 1 result is returned + When sending geocodejson search query "Hamburg" + | param | value | + | | | + Then at least 1 result is returned Examples: | parameter | value | diff --git a/test/bdd/steps/queries.py b/test/bdd/steps/queries.py index 1584d1ed..62bc295e 100644 --- a/test/bdd/steps/queries.py +++ b/test/bdd/steps/queries.py @@ -114,6 +114,9 @@ class SearchResponse(GenericResponse): self.parse_json() self.result = geojson_results_to_json_results(self.result) + def parse_geocodejson(self): + return self.parse_geojson() + def parse_html(self): content, errors = tidy_document(self.page, options={'char-encoding' : 'utf8'}) @@ -195,6 +198,9 @@ class ReverseResponse(GenericResponse): return self.result = geojson_results_to_json_results(self.result[0]) + def parse_geocodejson(self): + return self.parse_geojson() + def parse_xml(self): et = ET.fromstring(self.page) -- 2.39.5