Compare commits

..

19 Commits

Author SHA1 Message Date
Nicolas Roche e9fcbba3e4 toulouse-maelis: [functests] adding tests on capacities (#77634)
gitea/passerelle/pipeline/head This commit looks good Details
2023-06-22 17:38:30 +02:00
Nicolas Roche 297d0dd5db toulouse-maelis: [functests] update invoice test on extrasco (#77634) 2023-06-22 17:38:30 +02:00
Nicolas Roche 0ea7df17cf toulouse-maelis: [functests] update loisirs basket tests (#77634) 2023-06-22 17:38:30 +02:00
Nicolas Roche 52b794c975 toulouse-maelis: [functests] include ban zipcode into test (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche a577b95fe5 toulouse-maelis: [functests] add subscriptions out from Toulouse (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 78f89d48d7 toulouse-maelis: [functests] re-enabling tests on extra-sco (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 23e23450b5 toulouse-maelis: [functests] re-enabling tests on loisirs (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 8abd59cd05 toulouse-maelis: [functests] add test for adultes on perisco (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 75c5d2dfea toulouse-maelis: [functests] re-enable test on pericso (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 36b6d1e341 toulouse-maelis: [functests] improve tests on scolaire (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche aaccbaf9ce toulouse-maelis: [functests] re-enabling tests on ape (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 29f626492a toulouse-maelis: [functests] flagCom correction (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 667495eac5 toulouse-maelis: [functests] locate test family into Toulouse (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche f711b0debf toulouse-maelis: [functests] update referentials (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche a0fb5681ce toulouse-maelis: [functests] rename test families (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche e5bf8f78d6 toulouse-maelis: [functests] complete tests on school subscription (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 8eaa3a086f toulouse-maelis: [functests] add visa date to supplied documents (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 1ef18125d4 toulouse-maelis: [tools] correct tools (#77634) 2023-06-22 17:38:21 +02:00
Nicolas Roche 4a0d71b20e toulouse-maelis: [tools] set quantity on booking (#77634) 2023-06-21 09:51:47 +02:00
4 changed files with 3 additions and 46 deletions

View File

@ -16,7 +16,6 @@
import json
import os
import zipfile
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -418,10 +417,7 @@ class Demand(models.Model):
path = os.path.join(self.resource.output_dir, zip_file)
try:
content = get_file_content_from_zip(path, 'message.xml')
except zipfile.BadZipFile:
raise APIError('zipfile error')
content = get_file_content_from_zip(path, 'message.xml')
element = mdel.etree.fromstring(content)
majs = element.findall('ns2:Body/*/*/*/ns2:Maj', namespace)

View File

@ -215,16 +215,12 @@ class OpenGIS(BaseResource):
response = self.requests.get(self.wfs_service_url, params=params)
data = []
try:
json_response = response.json()
response = response.json()
except ValueError:
self.handle_opengis_error(response)
# if handle_opengis_error did not raise an error, we raise a generic one
raise APIError('OpenGIS Error: unparsable error', data={'content': repr(response.content[:1024])})
if not isinstance(json_response, dict) or 'features' not in json_response:
raise APIError(
'OpenGIS Error: bad result format', data={'content': repr(response.content[:1024])}
)
for feature in json_response['features']:
for feature in response['features']:
feature['text'] = feature['properties'].get(property_name)
data.append(feature)
return {'data': data}

View File

@ -551,13 +551,6 @@ def test_get_status(app, setup):
assert data['comment'] == 'Dossier accepté'
assert Demand.objects.get(demand_id='102-2-AEC-LA').status == 'accepted'
# bad zipfile
filepath = os.path.join(get_resource_base_dir(), 'test', 'outputs', '102-2-aec-la--4.zip')
with open(filepath, 'w') as f:
f.write(' ')
resp = app.get('/mdel/test/status', params={'demand_id': '102-2-AEC-LA'}, status=200)
assert resp.json['err_desc'] == 'zipfile error'
def test_get_status_unknown_demand(app, setup):
resp = app.get('/mdel/test/status', params={'demand_id': '1-14-ILE-LA'})

View File

@ -585,34 +585,6 @@ def test_get_feature_error2(mocked_get, app, connector):
assert '<ows:' in result['data']['content']
@mock.patch('passerelle.utils.Request.get')
def test_get_feature_bad_result(mocked_get, app, connector):
def keyerror(url, **kwargs):
if kwargs['params'].get('request') == 'GetCapabilities':
assert kwargs['params'].get('service')
return tests.utils.FakedResponse(status_code=200, content=FAKE_SERVICE_CAPABILITIES)
return tests.utils.FakedResponse(status_code=200, content=json.dumps({}))
endpoint = tests.utils.generic_endpoint_url('opengis', 'features', slug=connector.slug)
mocked_get.side_effect = keyerror
resp = app.get(endpoint, params={'type_names': 'ref_metro_limites_communales', 'property_name': 'nom'})
assert resp.json['err'] == 1
assert resp.json['err_desc'] == 'OpenGIS Error: bad result format'
assert resp.json['data'] == {'content': "'{}'"}
def typeerror(url, **kwargs):
if kwargs['params'].get('request') == 'GetCapabilities':
assert kwargs['params'].get('service')
return tests.utils.FakedResponse(status_code=200, content=FAKE_SERVICE_CAPABILITIES)
return tests.utils.FakedResponse(status_code=200, content=json.dumps([]))
mocked_get.side_effect = typeerror
resp = app.get(endpoint, params={'type_names': 'ref_metro_limites_communales', 'property_name': 'nom'})
assert resp.json['err'] == 1
assert resp.json['err_desc'] == 'OpenGIS Error: bad result format'
assert resp.json['data'] == {'content': "'[]'"}
@pytest.mark.parametrize(
"server_responses, version, typename_label",
[(geoserver_responses_v1_0_0, '1.0.0', 'typename'), (geoserver_responses, '2.0.0', 'typenames')],