add test for moreURL issue and debugging of test query contents

This commit is contained in:
Sarah Hoffmann
2017-01-01 17:58:21 +01:00
parent 65500927c2
commit d18bd14045
2 changed files with 16 additions and 2 deletions

View File

@@ -219,3 +219,10 @@ Feature: Simple Tests
When sending json search query "-21.0,-33.0" When sending json search query "-21.0,-33.0"
Then exactly 0 results are returned Then exactly 0 results are returned
Scenario: Country code selection is retained in more URL (#596)
When sending xml search query "Vaduz"
| countrycodes |
| pl,1,,invalid,undefined,%3Cb%3E,bo,, |
Then result header contains
| attr | value |
| more_url | .*&countrycodes=pl,bo&.* |

View File

@@ -8,6 +8,7 @@ import json
import os import os
import io import io
import re import re
import logging
from tidylib import tidy_document from tidylib import tidy_document
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import subprocess import subprocess
@@ -15,6 +16,8 @@ from urllib.parse import urlencode
from collections import OrderedDict from collections import OrderedDict
from nose.tools import * # for assert functions from nose.tools import * # for assert functions
logger = logging.getLogger(__name__)
BASE_SERVER_ENV = { BASE_SERVER_ENV = {
'HTTP_HOST' : 'localhost', 'HTTP_HOST' : 'localhost',
'HTTP_USER_AGENT' : 'Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0', 'HTTP_USER_AGENT' : 'Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0',
@@ -274,6 +277,8 @@ def send_api_query(endpoint, params, fmt, context):
'%s.php' % endpoint) '%s.php' % endpoint)
env['NOMINATIM_SETTINGS'] = context.nominatim.local_settings_file env['NOMINATIM_SETTINGS'] = context.nominatim.local_settings_file
logger.debug("Environment:" + json.dumps(env, sort_keys=True, indent=2))
if hasattr(context, 'http_headers'): if hasattr(context, 'http_headers'):
env.update(context.http_headers) env.update(context.http_headers)
@@ -285,14 +290,16 @@ def send_api_query(endpoint, params, fmt, context):
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(outp, err) = proc.communicate() (outp, err) = proc.communicate()
outp = outp.decode('utf-8')
logger.debug("Result: \n===============================\n"
+ outp + "\n===============================\n")
assert_equals(0, proc.returncode, assert_equals(0, proc.returncode,
"query.php failed with message: %s\noutput: %s" % (err, outp)) "query.php failed with message: %s\noutput: %s" % (err, outp))
assert_equals(0, len(err), "Unexpected PHP error: %s" % (err)) assert_equals(0, len(err), "Unexpected PHP error: %s" % (err))
outp = outp.decode('utf-8')
if outp.startswith('Status: '): if outp.startswith('Status: '):
status = int(outp[8:11]) status = int(outp[8:11])
else: else: