mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
bdd: complete coverage for API tests
Also removes some functions that are no longer used and fixes debug output where the tests found an issue.
This commit is contained in:
@@ -86,18 +86,6 @@ class SearchDescription
|
||||
$this->sType = $sType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this might be a full address search.
|
||||
*
|
||||
* @return bool True if the search contains name, address and housenumber.
|
||||
*/
|
||||
public function looksLikeFullAddress()
|
||||
{
|
||||
return (!empty($this->aName))
|
||||
&& (!empty($this->aAddress) || $this->sCountryCode)
|
||||
&& preg_match('/[0-9]+/', $this->sHouseNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any operator is set.
|
||||
*
|
||||
@@ -1027,7 +1015,7 @@ class SearchDescription
|
||||
'Name terms (stop words)' => $this->aNameNonSearch,
|
||||
'Address terms' => $this->aAddress,
|
||||
'Address terms (stop words)' => $this->aAddressNonSearch,
|
||||
'Address terms (full words)' => $this->aFullNameAddress,
|
||||
'Address terms (full words)' => $this->aFullNameAddress ?? '',
|
||||
'Special search' => $this->iOperator,
|
||||
'Class' => $this->sClass,
|
||||
'Type' => $this->sType,
|
||||
@@ -1039,7 +1027,7 @@ class SearchDescription
|
||||
public function dumpAsHtmlTableRow(&$aWordIDs)
|
||||
{
|
||||
$kf = function ($k) use (&$aWordIDs) {
|
||||
return $aWordIDs[$k];
|
||||
return $aWordIDs[$k] ?? '['.$k.']';
|
||||
};
|
||||
|
||||
echo '<tr>';
|
||||
|
||||
@@ -25,6 +25,39 @@ Feature: Parameters for Reverse API
|
||||
| -45.3,; |
|
||||
| gkjd,50 |
|
||||
|
||||
Scenario Outline: Zoom levels between 4 and 18 are allowed
|
||||
When sending reverse coordinates 47.14122383,9.52169581334
|
||||
| zoom |
|
||||
| <zoom> |
|
||||
Then exactly 1 result is returned
|
||||
And result addresses contain
|
||||
| country_code |
|
||||
| li |
|
||||
|
||||
Examples:
|
||||
| zoom |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
| 7 |
|
||||
| 8 |
|
||||
| 9 |
|
||||
| 10 |
|
||||
| 11 |
|
||||
| 12 |
|
||||
| 13 |
|
||||
| 14 |
|
||||
| 15 |
|
||||
| 16 |
|
||||
| 17 |
|
||||
| 18 |
|
||||
|
||||
Scenario: Non-numerical zoom levels return an error
|
||||
When sending reverse coordinates 47.14122383,9.52169581334
|
||||
| zoom |
|
||||
| adfe |
|
||||
Then a HTTP 400 is returned
|
||||
|
||||
Scenario Outline: Reverse Geocoding with extratags
|
||||
When sending <format> reverse coordinates 47.1395013150811,9.522098077031046
|
||||
| extratags |
|
||||
|
||||
@@ -131,3 +131,7 @@ Feature: Simple Reverse Tests
|
||||
| 48.966 | 8.448.2 |
|
||||
| Nan | 8.448 |
|
||||
| 48.966 | Nan |
|
||||
|
||||
Scenario: Reverse Debug output returns no errors
|
||||
When sending debug reverse coordinates 47.11,9.57
|
||||
Then a HTTP 200 is returned
|
||||
|
||||
@@ -80,6 +80,15 @@ Feature: Search queries
|
||||
| class | type |
|
||||
| amenity | restaurant |
|
||||
|
||||
Scenario: Search with specific amenity also work in country
|
||||
When sending json search query "restaurants in liechtenstein" with address
|
||||
Then result addresses contain
|
||||
| country |
|
||||
| Liechtenstein |
|
||||
And results contain
|
||||
| class | type |
|
||||
| amenity | restaurant |
|
||||
|
||||
Scenario: Search with key-value amenity
|
||||
When sending json search query "[club=scout] Vaduz"
|
||||
Then results contain
|
||||
@@ -114,6 +123,19 @@ Feature: Search queries
|
||||
| class | type |
|
||||
| leisure | firepit |
|
||||
|
||||
Scenario Outline: Key/value search near given coordinate can be restricted to country
|
||||
When sending json search query "[natural=peak] 47.06512,9.53965" with address
|
||||
| countrycodes |
|
||||
| <cc> |
|
||||
Then result addresses contain
|
||||
| country_code |
|
||||
| <cc> |
|
||||
|
||||
Examples:
|
||||
| cc |
|
||||
| li |
|
||||
| ch |
|
||||
|
||||
Scenario: Name search near given coordinate
|
||||
When sending json search query "sporry" with address
|
||||
Then result addresses contain
|
||||
@@ -146,6 +168,14 @@ Feature: Search queries
|
||||
| li |
|
||||
Then exactly 0 results are returned
|
||||
|
||||
Scenario: Country searches only return results for the given country
|
||||
When sending search query "Ans Trail" with address
|
||||
| countrycodes |
|
||||
| li |
|
||||
Then result addresses contain
|
||||
| country_code |
|
||||
| li |
|
||||
|
||||
# https://trac.openstreetmap.org/ticket/5094
|
||||
Scenario: housenumbers are ordered by complete match first
|
||||
When sending json search query "Austrasse 11, Vaduz" with address
|
||||
@@ -182,3 +212,7 @@ Feature: Search queries
|
||||
Then result addresses contain
|
||||
| ID | town |
|
||||
| 0 | Vaduz |
|
||||
|
||||
Scenario: Search can handle complex query word sets
|
||||
When sending search query "aussenstelle universitat lichtenstein wachterhaus aussenstelle universitat lichtenstein wachterhaus aussenstelle universitat lichtenstein wachterhaus aussenstelle universitat lichtenstein wachterhaus"
|
||||
Then a HTTP 200 is returned
|
||||
|
||||
@@ -195,3 +195,16 @@ Feature: Simple Tests
|
||||
Then result header contains
|
||||
| attr | value |
|
||||
| more_url | .*&countrycodes=pl%2Cbo&.* |
|
||||
|
||||
Scenario Outline: Search debug output does not return errors
|
||||
When sending debug search query "<query>"
|
||||
Then a HTTP 200 is returned
|
||||
|
||||
Examples:
|
||||
| query |
|
||||
| Liechtenstein |
|
||||
| Triesen |
|
||||
| Pfarrkirche |
|
||||
| Landstr 27 Steinort, Triesenberg, 9495 |
|
||||
| 9497 |
|
||||
| restaurant in triesen |
|
||||
|
||||
@@ -50,7 +50,7 @@ class GenericResponse:
|
||||
self.result = []
|
||||
self.header = dict()
|
||||
|
||||
if errorcode == 200:
|
||||
if errorcode == 200 and fmt != 'debug':
|
||||
getattr(self, '_parse_' + fmt)()
|
||||
|
||||
def _parse_json(self):
|
||||
|
||||
@@ -79,7 +79,7 @@ def query_cmd(context, query, dups):
|
||||
context.response = SearchResponse(outp, 'json')
|
||||
|
||||
def send_api_query(endpoint, params, fmt, context):
|
||||
if fmt is not None:
|
||||
if fmt is not None and fmt.strip() != 'debug':
|
||||
params['format'] = fmt.strip()
|
||||
if context.table:
|
||||
if context.table.headings[0] == 'param':
|
||||
@@ -148,6 +148,8 @@ def website_search_request(context, fmt, query, addr):
|
||||
params['q'] = query
|
||||
if addr is not None:
|
||||
params['addressdetails'] = '1'
|
||||
if fmt and fmt.strip() == 'debug':
|
||||
params['debug'] = '1'
|
||||
|
||||
outp, status = send_api_query('search', params, fmt, context)
|
||||
|
||||
@@ -160,6 +162,8 @@ def website_reverse_request(context, fmt, lat, lon):
|
||||
params['lat'] = lat
|
||||
if lon is not None:
|
||||
params['lon'] = lon
|
||||
if fmt and fmt.strip() == 'debug':
|
||||
params['debug'] = '1'
|
||||
|
||||
outp, status = send_api_query('reverse', params, fmt, context)
|
||||
|
||||
@@ -203,7 +207,8 @@ def validate_result_number(context, operator, number):
|
||||
|
||||
@then(u'a HTTP (?P<status>\d+) is returned')
|
||||
def check_http_return_status(context, status):
|
||||
assert context.response.errorcode == int(status)
|
||||
assert context.response.errorcode == int(status), \
|
||||
"Return HTTP status is {}.".format(context.response.errorcode)
|
||||
|
||||
@then(u'the page contents equals "(?P<text>.+)"')
|
||||
def check_page_content_equals(context, text):
|
||||
|
||||
Reference in New Issue
Block a user