Compare commits
16 Commits
5f6a4407bb
...
f65b930a2f
Author | SHA1 | Date |
---|---|---|
Nicolas Roche | f65b930a2f | |
Nicolas Roche | 978a15fdbe | |
Nicolas Roche | 79ebceb459 | |
Nicolas Roche | db7a2fc925 | |
Nicolas Roche | 6f461e6366 | |
Nicolas Roche | 433afc6a24 | |
Nicolas Roche | 13450d32a5 | |
Nicolas Roche | 07975f7685 | |
Nicolas Roche | 0c4571384b | |
Nicolas Roche | 31d9c6e796 | |
Nicolas Roche | 87063d9485 | |
Nicolas Roche | ad7ac9e0e7 | |
Nicolas Roche | a3168ae8ad | |
Nicolas Roche | 5b617a3867 | |
Nicolas Roche | 71e04a76df | |
Nicolas Roche | 7c75504cf7 |
|
@ -2,7 +2,7 @@
|
|||
"number": "N/A",
|
||||
"category": "BI",
|
||||
"situation": "MARI",
|
||||
"flagCom": true,
|
||||
"flagCom": false,
|
||||
"nbChild": 3,
|
||||
"nbTotalChild": 4,
|
||||
"nbAES": "1",
|
||||
|
@ -72,8 +72,7 @@
|
|||
"countryCode": null,
|
||||
"cdDepartment": "19",
|
||||
"communeCode_text": "BRIVE-LA-GAILLARDE",
|
||||
"cdDepartment_text": "CORREZE",
|
||||
"zipCode": "19100"
|
||||
"cdDepartment_text": "CORREZE"
|
||||
},
|
||||
"dietcode": "MENU_AV",
|
||||
"bPhoto": true,
|
||||
|
|
|
@ -70,8 +70,7 @@
|
|||
"countryCode": null,
|
||||
"cdDepartment": "19",
|
||||
"communeCode_text": "BRIVE-LA-GAILLARDE",
|
||||
"cdDepartment_text": "CORREZE",
|
||||
"zipCode": "19100"
|
||||
"cdDepartment_text": "CORREZE"
|
||||
},
|
||||
"adresse": {
|
||||
"idStreet": "2317",
|
||||
|
@ -146,8 +145,7 @@
|
|||
"countryCode": null,
|
||||
"cdDepartment": "19",
|
||||
"communeCode_text": "BRIVE-LA-GAILLARDE",
|
||||
"cdDepartment_text": "CORREZE",
|
||||
"zipCode": "19100"
|
||||
"cdDepartment_text": "CORREZE"
|
||||
},
|
||||
"dietcode": "MENU_AV",
|
||||
"bPhoto": true,
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
"countryCode": null,
|
||||
"cdDepartment": "19",
|
||||
"communeCode_text": "BRIVE-LA-GAILLARDE",
|
||||
"cdDepartment_text": "CORREZE",
|
||||
"zipCode": "19100"
|
||||
"cdDepartment_text": "CORREZE"
|
||||
},
|
||||
"adresse": {
|
||||
"idStreet": null,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"number": "N/A",
|
||||
"category": "BI",
|
||||
"situation": "MARI",
|
||||
"flagCom": true,
|
||||
"flagCom": false,
|
||||
"nbChild": 3,
|
||||
"nbTotalChild": 4,
|
||||
"nbAES": "1",
|
||||
|
@ -61,8 +61,7 @@
|
|||
"countryCode": null,
|
||||
"cdDepartment": "19",
|
||||
"communeCode_text": "BRIVE-LA-GAILLARDE",
|
||||
"cdDepartment_text": "CORREZE",
|
||||
"zipCode": "19100"
|
||||
"cdDepartment_text": "CORREZE"
|
||||
},
|
||||
"adresse": {
|
||||
"idStreet": null,
|
||||
|
@ -136,8 +135,7 @@
|
|||
"countryCode": null,
|
||||
"cdDepartment": "19",
|
||||
"communeCode_text": "BRIVE-LA-GAILLARDE",
|
||||
"cdDepartment_text": "CORREZE",
|
||||
"zipCode": "19100"
|
||||
"cdDepartment_text": "CORREZE"
|
||||
},
|
||||
"dietcode": "MENU_AV",
|
||||
"bPhoto": true,
|
||||
|
|
|
@ -3,13 +3,8 @@ import datetime
|
|||
import pytest
|
||||
import requests
|
||||
|
||||
from .conftest import link, unlink
|
||||
|
||||
|
||||
def test_create_nursery_demand_on_existing_child(conn, create_data):
|
||||
unlink(conn, create_data['name_id'])
|
||||
link(conn, create_data)
|
||||
|
||||
url = conn + '/get-nursery-geojson'
|
||||
resp = requests.get(url)
|
||||
resp.raise_for_status()
|
||||
|
@ -62,9 +57,6 @@ def test_create_nursery_demand_on_existing_child(conn, create_data):
|
|||
|
||||
|
||||
def test_create_nursery_demand_adding_new_child(conn, create_data):
|
||||
unlink(conn, create_data['name_id'])
|
||||
link(conn, create_data)
|
||||
|
||||
url = conn + '/get-nursery-geojson'
|
||||
resp = requests.get(url)
|
||||
resp.raise_for_status()
|
||||
|
@ -78,7 +70,6 @@ def test_create_nursery_demand_adding_new_child(conn, create_data):
|
|||
res = resp.json()
|
||||
assert res['err'] == 0
|
||||
nb_childs = len(res['data']['childList'])
|
||||
assert 'NELSON' not in [x['firstname'] for x in res['data']['childList']]
|
||||
|
||||
url = conn + '/create-nursery-demand'
|
||||
payload = {
|
||||
|
@ -111,5 +102,4 @@ def test_create_nursery_demand_adding_new_child(conn, create_data):
|
|||
res = resp.json()
|
||||
assert res['err'] == 0
|
||||
assert len(res['data']['childList']) == nb_childs + 1
|
||||
assert 'NELSON' in [x['firstname'] for x in res['data']['childList']]
|
||||
assert res['data']['childList'][nb_childs]['num'] == child_id
|
||||
|
|
|
@ -205,10 +205,11 @@ def test_perisco_recurrent_week(conn, create_data, perisco_subscribe_info, refer
|
|||
resp = requests.get(url, params=params)
|
||||
resp.raise_for_status()
|
||||
assert resp.json()['err'] == 0
|
||||
assert len(resp.json()['data']) == 1
|
||||
assert len(resp.json()['data']) == 2
|
||||
assert resp.json()['data'][0]['id'] == perisco_subscribe_info['activity']['id']
|
||||
assert [(x['text'], x['libelle'], x['libelle2']) for x in resp.json()['data']] == [
|
||||
('Temps du midi', 'TEST TEMPS DU MIDI 22/23', 'Temps du midi'),
|
||||
('Temps du midi', 'TEST TEMPS DU MIDI 22/23', 'Temps du midi'),
|
||||
]
|
||||
|
||||
# get recurent-week gabarit
|
||||
|
|
|
@ -13,7 +13,6 @@ def test_catalog_personnalise_extrasco(extrasco_subscribe_info):
|
|||
'quantity': None,
|
||||
'unitPrice': 11.5,
|
||||
}
|
||||
assert item['activity']['activityPortail']['blocNoteList'] == []
|
||||
|
||||
|
||||
def test_catalog_personnalise_extrasco2(extrasco_subscribe_info2):
|
||||
|
@ -27,7 +26,6 @@ def test_catalog_personnalise_extrasco2(extrasco_subscribe_info2):
|
|||
'quantity': None,
|
||||
'unitPrice': 11.5,
|
||||
}
|
||||
assert item['activity']['activityPortail']['blocNoteList'] == []
|
||||
|
||||
|
||||
def test_direct_subscribe(conn, create_data, extrasco_subscribe_info, reference_year):
|
||||
|
|
|
@ -265,9 +265,6 @@ def test_basket_subscribe_extrasco2(conn, create_data, extrasco_subscribe_info2,
|
|||
assert data['controlResult'] == {'controlOK': True, 'message': None}
|
||||
assert data['basket']['codeRegie'] == 105
|
||||
assert len({x['personneInfo']['numPerson'] for x in data['basket']['lignes']}) == 1
|
||||
import pdb
|
||||
|
||||
pdb.set_trace()
|
||||
assert len({x['idIns'] for x in data['basket']['lignes']}) == 1 # 3 expected
|
||||
|
||||
assert len(subscriptions(create_data['bart_num'])) == 2 # redoundant
|
||||
|
|
|
@ -35,7 +35,7 @@ SIGN_REQUEST_SCHEMA = {
|
|||
'title': '',
|
||||
'description': '',
|
||||
'type': 'object',
|
||||
'required': ['file', 'recipients_emails', 'eppn'],
|
||||
'required': ['file', 'recipients_emails', 'create_by_eppn'],
|
||||
'unflatten': True,
|
||||
'properties': collections.OrderedDict(
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ SIGN_REQUEST_SCHEMA = {
|
|||
'enum': ['visa', 'pdfImageStamp', 'certSign', 'nexuSign'],
|
||||
'default': 'pdfImageStamp',
|
||||
},
|
||||
'eppn': {'type': 'string', 'description': 'EPPN of the sign request owner'},
|
||||
'create_by_eppn': {'type': 'string', 'description': 'EPPN of the sign request owner'},
|
||||
'title': {'type': 'string', 'description': 'Title'},
|
||||
'target_url': {
|
||||
'type': 'string',
|
||||
|
@ -114,7 +114,7 @@ SIGN_REQUEST_WITH_WORKFLOW_SCHEMA = {
|
|||
'title': '',
|
||||
'description': '',
|
||||
'type': 'object',
|
||||
'required': ['file', 'create_by_eppn', 'workflow_id'],
|
||||
'required': ['file', 'eppn', 'workflow_id'],
|
||||
'unflatten': True,
|
||||
'properties': collections.OrderedDict(
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ SIGN_REQUEST_WITH_WORKFLOW_SCHEMA = {
|
|||
'description': 'Steps numbers were every recipient has to sign',
|
||||
'items': {'type': 'string'},
|
||||
},
|
||||
'create_by_eppn': {'type': 'string', 'description': 'EPPN of the sign request owner'},
|
||||
'eppn': {'type': 'string', 'description': 'EPPN of the sign request owner'},
|
||||
'workflow_id': {'type': 'string', 'description': 'Identifier of the workflow'},
|
||||
'title': {'type': 'string', 'description': 'Title'},
|
||||
'target_urls': {
|
||||
|
@ -255,7 +255,7 @@ class EsupSignature(BaseResource, HTTPResource):
|
|||
'force_all_sign': 'false',
|
||||
'comment': 'a comment',
|
||||
'sign_type': 'pdfImageStamp',
|
||||
'eppn': 'aa@foo.com',
|
||||
'create_by_eppn': 'aa@foo.com',
|
||||
'title': 'a title',
|
||||
'target_url': 'smb://foo.bar/location-1/',
|
||||
},
|
||||
|
@ -279,7 +279,7 @@ class EsupSignature(BaseResource, HTTPResource):
|
|||
'recipientsCCEmails': clean_list(post_data.get('recipients_cc_emails', [])),
|
||||
'comment': post_data.get('comment', ''),
|
||||
'signType': post_data.get('sign_type', 'pdfImageStamp'),
|
||||
'eppn': post_data['eppn'],
|
||||
'createByEppn': post_data['create_by_eppn'],
|
||||
'title': post_data.get('title', ''),
|
||||
'targetUrl': post_data.get('target_url', ''),
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ class EsupSignature(BaseResource, HTTPResource):
|
|||
'content': 'JVBERi0xL...(base64 PDF)...',
|
||||
},
|
||||
'workflow_id': '99',
|
||||
'create_by_eppn': 'aa@foo.com',
|
||||
'eppn': 'aa@foo.com',
|
||||
'title': 'a title',
|
||||
'recipients_emails/0': '0*xx@foo.com',
|
||||
'recipients_emails/1': '0*yy@foo.com',
|
||||
|
@ -345,7 +345,7 @@ class EsupSignature(BaseResource, HTTPResource):
|
|||
}
|
||||
|
||||
params = {
|
||||
'createByEppn': post_data['create_by_eppn'],
|
||||
'createByEppn': post_data['eppn'],
|
||||
'title': post_data.get('title', ''),
|
||||
'recipientsEmails': clean_list(post_data.get('recipients_emails', [])),
|
||||
'allSignToCompletes': clean_list(post_data.get('all_sign_to_completes', [])),
|
||||
|
|
|
@ -23,47 +23,12 @@ from django.db.models import JSONField
|
|||
from django.utils.encoding import force_bytes
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from jsonschema import ValidationError, validate, validators
|
||||
from requests import RequestException
|
||||
|
||||
from passerelle.base.models import BaseResource
|
||||
from passerelle.utils.api import endpoint
|
||||
from passerelle.utils.jsonresponse import APIError
|
||||
|
||||
GEOJSON_SCHEMA = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'features': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'properties': {
|
||||
'type': 'object',
|
||||
},
|
||||
'geometry': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'type': {
|
||||
'type': 'string',
|
||||
},
|
||||
'coordinates': {
|
||||
'type': 'array',
|
||||
'minItems': 2,
|
||||
'items': {
|
||||
'oneOf': [{'type': 'number'}, {'type': 'string'}],
|
||||
},
|
||||
},
|
||||
},
|
||||
'required': ['type', 'coordinates'],
|
||||
},
|
||||
},
|
||||
'required': ['properties', 'geometry'],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class AddressCacheModel(models.Model):
|
||||
api_id = models.CharField(max_length=32, unique=True)
|
||||
|
@ -135,18 +100,6 @@ class Photon(BaseResource):
|
|||
result['id'] = hashlib.md5(force_bytes(dict_dump)).hexdigest()
|
||||
return result
|
||||
|
||||
def validate_geojson(self, response_json):
|
||||
validator = validators.validator_for(GEOJSON_SCHEMA)
|
||||
validator.META_SCHEMA['properties'].pop('description', None)
|
||||
validator.META_SCHEMA['properties'].pop('title', None)
|
||||
try:
|
||||
validate(response_json, GEOJSON_SCHEMA)
|
||||
except ValidationError as e:
|
||||
error_msg = e.message
|
||||
if e.path:
|
||||
error_msg = '%s: %s' % ('/'.join(map(str, e.path)), error_msg)
|
||||
raise APIError(error_msg)
|
||||
|
||||
@endpoint(
|
||||
pattern='(?P<q>.+)?$',
|
||||
description=_('Addresses list'),
|
||||
|
@ -201,7 +154,6 @@ class Photon(BaseResource):
|
|||
response_json = result_response.json()
|
||||
except ValueError:
|
||||
raise APIError('invalid photon response (%r)' % result_response.content[:1024])
|
||||
self.validate_geojson(response_json)
|
||||
|
||||
result = []
|
||||
for feature in response_json.get('features'):
|
||||
|
@ -267,7 +219,6 @@ class Photon(BaseResource):
|
|||
response_json = result_response.json()
|
||||
except ValueError:
|
||||
raise APIError('invalid photon response (%r)' % result_response.content[:1024])
|
||||
self.validate_geojson(response_json)
|
||||
|
||||
result = None
|
||||
for feature in response_json.get('features'):
|
||||
|
|
|
@ -44,7 +44,8 @@ class SNE(BaseResource, HTTPResource):
|
|||
@property
|
||||
def cert_public_bytes(self):
|
||||
with self.client_certificate.open('rb') as f:
|
||||
cert = x509.load_pem_x509_certificate(f.read())
|
||||
certs = x509.load_pem_x509_certificates(f.read())
|
||||
cert = certs[0]
|
||||
return cert.public_bytes(encoding=serialization.Encoding.PEM)
|
||||
|
||||
def check_status(self):
|
||||
|
|
|
@ -405,8 +405,6 @@ Response :
|
|||
data = sudsobject_to_dict(resp)
|
||||
else:
|
||||
data = self._rest_call('getMail', params=params)
|
||||
if not data.get('motifsrejet'):
|
||||
data['motifsrejet'] = None
|
||||
return {'data': data}
|
||||
|
||||
@endpoint(
|
||||
|
|
|
@ -107,11 +107,6 @@ class GrenobleGRU(BaseResource):
|
|||
payload = {'id': data['application_id']}
|
||||
payload['dem_comp'] = types_params['dem_comp'] = data.get('dem_comp', 'Voirie')
|
||||
|
||||
for key, value in data.items():
|
||||
if key.endswith('_phone'):
|
||||
phone = ''.join(x for x in value if x in '0123456789')
|
||||
data[key] = phone
|
||||
|
||||
payload.update(
|
||||
{
|
||||
# applicant informations
|
||||
|
|
|
@ -2426,7 +2426,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
'calendarLetter': None,
|
||||
'isPresent': False,
|
||||
}
|
||||
for item in post_data.get('recurrent_week') or []:
|
||||
for item in post_data.get('recurrent_week'):
|
||||
day_num, key = item.split('-')
|
||||
recurrent_week[day_num] = {
|
||||
'dayNum': day_num,
|
||||
|
|
|
@ -31,13 +31,13 @@ def test_new(app, connector):
|
|||
},
|
||||
'recipients_emails/0': 'foo@invalid',
|
||||
'recipients_emails/1': 'bar@invalid',
|
||||
'eppn': 'baz@invalid',
|
||||
'create_by_eppn': 'baz@invalid',
|
||||
'title': 'a title',
|
||||
}
|
||||
with responses.RequestsMock() as rsps:
|
||||
query_params = {
|
||||
'recipientsEmails': ['foo@invalid', 'bar@invalid'],
|
||||
'eppn': 'baz@invalid',
|
||||
'createByEppn': 'baz@invalid',
|
||||
'title': 'a title',
|
||||
'signType': 'pdfImageStamp',
|
||||
'pending': True,
|
||||
|
@ -67,7 +67,7 @@ def test_new_with_workflow(app, connector):
|
|||
'content_type': 'text/plain',
|
||||
},
|
||||
'workflow_id': '99',
|
||||
'create_by_eppn': 'aa@foo.com',
|
||||
'eppn': 'aa@foo.com',
|
||||
'title': 'a title',
|
||||
'recipients_emails/0': '0*xx@foo.com',
|
||||
'recipients_emails/1': '0*yy@foo.com',
|
||||
|
|
|
@ -521,7 +521,7 @@ def test_greco_rest_answer_ok(app, rest_conn):
|
|||
json={
|
||||
'iddemande': 'DWPQGCTS',
|
||||
'idgreco': '538554',
|
||||
'motifsrejet': '',
|
||||
'motifsrejet': None,
|
||||
'etat': None,
|
||||
'message': {
|
||||
'bcc': {'item': []},
|
||||
|
|
|
@ -229,7 +229,6 @@ def test_demand_creation_params(app, setup):
|
|||
payload = BASIC_PAYLOAD.copy()
|
||||
payload['intervention_free_address'] = '169, rue du Château'
|
||||
payload['applicant_free_address'] = '1, rue de l\'Est'
|
||||
payload['applicant_phone'] = '01-02.03 04 05'
|
||||
app.post_json(
|
||||
reverse(
|
||||
'generic-endpoint',
|
||||
|
@ -244,7 +243,6 @@ def test_demand_creation_params(app, setup):
|
|||
assert request_post.call_args[1]['data']['dem_pav'] == 'déchetterie'
|
||||
assert request_post.call_args[1]['data']['dem_reponse'] == 0
|
||||
assert request_post.call_args[1]['data']['obs_description_probleme'] == 'thank you '
|
||||
assert request_post.call_args[1]['data']['dem_tel'] == '0102030405'
|
||||
|
||||
payload['applicant_requires_reply'] = True
|
||||
payload['urgent_demand'] = 'True'
|
||||
|
|
|
@ -333,28 +333,3 @@ def test_photon_non_json(mocked_get, app, photon):
|
|||
resp = app.get('/photon/%s/reverse' % photon.slug, params={'lat': '0', 'lon': '0'}, status=200)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "invalid photon response (b'xxx')"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'endpoint', ['/photon/test/addresses', '/photon/test/search', '/photon/test/reverse']
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
'content',
|
||||
[
|
||||
'',
|
||||
'{"features": ""}',
|
||||
'{"features": null}',
|
||||
'{"features": [null]}',
|
||||
'{"features": [{}]}',
|
||||
'{"features": [{"properties": null, "geometry": null}]}',
|
||||
'{"features": [{"properties": {}, "geometry": {}}]}',
|
||||
'{"features": [{"properties": {}, "geometry": {"type": ""}}]}',
|
||||
'{"features": [{"properties": {}, "geometry": {"type": "", "coordinates": null}}]}',
|
||||
'{"features": [{"properties": {}, "geometry": {"type": "", "coordinates": [42]}}]}',
|
||||
],
|
||||
)
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
def test_photon_bad_geojson_response(mocked_get, content, endpoint, app, photon):
|
||||
mocked_get.return_value = tests.utils.FakedResponse(content=content, status_code=200)
|
||||
resp = app.get(endpoint, params={'q': 'plop', 'lat': 48, 'lon': 2})
|
||||
assert resp.json['err'] == 1
|
||||
|
|
|
@ -5777,38 +5777,6 @@ def test_update_recurrent_week_empty(family_service, activity_service, con, app)
|
|||
assert resp.json['data'] == 'ok'
|
||||
|
||||
|
||||
def test_update_recurrent_week_null(family_service, activity_service, con, app):
|
||||
def request_check(request):
|
||||
assert serialize_object(request.dayWeekInfoList) == [
|
||||
{'dayNum': 1, 'isPresent': False, 'isOpen': None, 'calendarLetter': None},
|
||||
{'dayNum': 2, 'isPresent': False, 'isOpen': None, 'calendarLetter': None},
|
||||
{'dayNum': 3, 'isPresent': False, 'isOpen': None, 'calendarLetter': None},
|
||||
{'dayNum': 4, 'isPresent': False, 'isOpen': None, 'calendarLetter': None},
|
||||
{'dayNum': 5, 'isPresent': False, 'isOpen': None, 'calendarLetter': None},
|
||||
{'dayNum': 6, 'isPresent': False, 'isOpen': None, 'calendarLetter': None},
|
||||
{'dayNum': 7, 'isPresent': False, 'isOpen': None, 'calendarLetter': None},
|
||||
]
|
||||
|
||||
family_service.add_soap_response('readFamily', get_xml_file('R_read_family.xml'))
|
||||
activity_service.add_soap_response(
|
||||
'updateWeekCalendar',
|
||||
get_xml_file('R_update_week_calendar.xml'),
|
||||
request_check=request_check,
|
||||
)
|
||||
url = get_endpoint('update-recurrent-week')
|
||||
params = {
|
||||
'person_id': '613880',
|
||||
'activity_id': 'A10049327682',
|
||||
'start_date': '2023-04-01',
|
||||
'end_date': '2023-04-30',
|
||||
'recurrent_week': None,
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?family_id=311323', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == 'ok'
|
||||
|
||||
|
||||
def test_update_recurrent_week_not_linked_error(con, app):
|
||||
url = get_endpoint('update-recurrent-week')
|
||||
params = {
|
||||
|
@ -6050,9 +6018,6 @@ def test_read_activity_list(activity_service, con, app):
|
|||
resp = app.get(url, params=params)
|
||||
assert resp.json['err'] == 0
|
||||
assert len(resp.json['data']) == 8
|
||||
import pdb
|
||||
|
||||
pdb.set_trace()
|
||||
assert [
|
||||
(
|
||||
x['id'],
|
||||
|
|
Loading…
Reference in New Issue