99 |
99 |
"type": "FeatureCollection"
|
100 |
100 |
}'''
|
101 |
101 |
|
|
102 |
FAKE_ERROR = u'<ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 https://sigmetropole.lametro.fr/geoserver/schemas/ows/1.1.0/owsAll.xsd">\n <ows:Exception exceptionCode="NoApplicableCode">\n <ows:ExceptionText>Could not parse CQL filter list.\nEncountered &quot;BIS&quot; at line 1, column 129.\nWas expecting one of:\n &lt;EOF&gt; \n &quot;and&quot; ...\n &quot;or&quot; ...\n &quot;;&quot; ...\n &quot;/&quot; ...\n &quot;*&quot; ...\n &quot;+&quot; ...\n &quot;-&quot; ...\n Parsing : strEqualsIgnoreCase(nom_commune, &apos;Grenoble&apos;) = true AND strEqualsIgnoreCase(nom_voie, &apos;rue albert recoura&apos;) = true AND numero=8 BIS.</ows:ExceptionText>\n </ows:Exception>\n</ows:ExceptionReport>\n'
|
|
103 |
|
102 |
104 |
|
103 |
105 |
@pytest.fixture
|
104 |
106 |
def connector(db):
|
... | ... | |
112 |
114 |
return utils.FakedResponse(status_code=200, content=FAKE_SERVICE_CAPABILITIES)
|
113 |
115 |
return utils.FakedResponse(status_code=200, content=FAKE_FEATURES_JSON)
|
114 |
116 |
|
|
117 |
def geoserver_responses_errors(url, **kwargs):
|
|
118 |
if kwargs['params'].get('request') == 'GetCapabilities':
|
|
119 |
return utils.FakedResponse(status_code=200, content=FAKE_SERVICE_CAPABILITIES)
|
|
120 |
return utils.FakedResponse(status_code=200, content=FAKE_ERROR)
|
|
121 |
|
115 |
122 |
@mock.patch('passerelle.utils.LoggedRequest.get')
|
116 |
123 |
def test_feature_info(mocked_get, app, connector):
|
117 |
124 |
endpoint = utils.generic_endpoint_url('opengis', 'feature_info', slug=connector.slug)
|
... | ... | |
184 |
191 |
params.pop('cql_filter')
|
185 |
192 |
resp = app.get(endpoint, params=params)
|
186 |
193 |
assert 'CQL_FILTER' not in mocked_get.call_args[1]['params']
|
|
194 |
|
|
195 |
@mock.patch('passerelle.utils.LoggedRequest.get')
|
|
196 |
def test_get_feature_error(mocked_get, app, connector):
|
|
197 |
endpoint = utils.generic_endpoint_url('opengis', 'features', slug=connector.slug)
|
|
198 |
assert endpoint == '/opengis/test/features'
|
|
199 |
mocked_get.side_effect = geoserver_responses_errors
|
|
200 |
resp = app.get(endpoint, params={'type_names': 'ref_metro_limites_communales', 'property_name': 'nom'})
|
|
201 |
assert mocked_get.call_args[1]['params']['REQUEST'] == 'GetFeature'
|
|
202 |
assert mocked_get.call_args[1]['params']['PROPERTYNAME'] == 'nom'
|
|
203 |
assert mocked_get.call_args[1]['params']['TYPENAMES'] == 'ref_metro_limites_communales'
|
|
204 |
assert mocked_get.call_args[1]['params']['OUTPUTFORMAT'] == 'json'
|
|
205 |
assert mocked_get.call_args[1]['params']['SERVICE'] == 'WFS'
|
|
206 |
assert mocked_get.call_args[1]['params']['VERSION'] == connector.get_wfs_service_version()
|
|
207 |
result = resp.json
|
|
208 |
assert result['err'] == 1
|
|
209 |
assert result['err_desc'] == 'OpenGIS Error: NoApplicableCode'
|
|
210 |
assert 'Could not parse' in result['data']['text']
|
187 |
|
-
|