From 1fd483643b3619ef5409206292efb2563bda230e Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Mon, 26 Apr 2021 23:01:06 +0200 Subject: [PATCH] add tests for different scripts --- test/bdd/db/import/naming.feature | 21 +++++++++++++++++++++ test/bdd/steps/http_responses.py | 8 +++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/test/bdd/db/import/naming.feature b/test/bdd/db/import/naming.feature index f3019e2a..bb29d2a3 100644 --- a/test/bdd/db/import/naming.feature +++ b/test/bdd/db/import/naming.feature @@ -37,3 +37,24 @@ Feature: Import and search of names Then placex contains | object | country_code | name | name+name:fi | name+name:de | | N1 | de | german | finnish | local | + + Scenario Outline: Names in any script can be found + Given the places + | osm | class | type | name | + | N1 | place | hamlet | | + When importing + And sending search query "" + Then results contain + | osm | + | N1 | + + Examples: + | name | + | Berlin | + | 北京 | + | Вологда | + | Αθήνα | + | القاهرة | + | រាជធានីភ្នំពេញ | + | 東京都 | + | ပုဗ္ဗသီရိ | diff --git a/test/bdd/steps/http_responses.py b/test/bdd/steps/http_responses.py index beafcd9e..247a397b 100644 --- a/test/bdd/steps/http_responses.py +++ b/test/bdd/steps/http_responses.py @@ -8,6 +8,8 @@ import xml.etree.ElementTree as ET from check_functions import Almost +OSM_TYPE = {'N' : 'node', 'W' : 'way', 'R' : 'relation'} + def _geojson_result_to_json_result(geojson_result): result = geojson_result['properties'] result['geojson'] = geojson_result['geometry'] @@ -131,7 +133,11 @@ class GenericResponse: if name == 'ID': pass elif name == 'osm': - self.assert_field(i, 'osm_type', value[0]) + assert 'osm_type' in self.result[i], \ + "Result row {} has no field 'osm_type'.\nFull row: {}"\ + .format(i, json.dumps(self.result[i], indent=4)) + assert self.result[i]['osm_type'] in (OSM_TYPE[value[0]], value[0]), \ + BadRowValueAssert(self, i, 'osm_type', value) self.assert_field(i, 'osm_id', value[1:]) elif name == 'centroid': lon, lat = value.split(' ') -- 2.39.5