toulouse-foederis: send offer id and application type when creating application (#81346)
This commit is contained in:
parent
199075ed80
commit
520e6a818b
|
@ -439,6 +439,10 @@ class Resource(BaseResource, HTTPResource):
|
|||
document_data[document_field] = results[0][response_field]
|
||||
|
||||
document_data['id'] = announce_id = str(response_announce['id'])
|
||||
|
||||
# This field must be provided when applying to an existing announce via create-application : save it
|
||||
document_data['offer_id'] = recrut_id
|
||||
|
||||
external_id = f'announce-{announce_id}'
|
||||
text = document_data['text'] = document_data['intitule']
|
||||
if response_announce.get('pdf_ddr'):
|
||||
|
@ -505,6 +509,7 @@ class Resource(BaseResource, HTTPResource):
|
|||
'emploi': 'R15017962',
|
||||
'niveau_diplome': 'R1249737',
|
||||
'habilitation': 'R1276043',
|
||||
'offre': FIELD_ANNOUNCE_FKEY_DEMANDE_DE_PERSONNEL,
|
||||
}
|
||||
|
||||
def update_referentiels(self):
|
||||
|
@ -598,9 +603,18 @@ class Resource(BaseResource, HTTPResource):
|
|||
|
||||
formatted_phone = f'+{parsed_phone.country_code} {parsed_phone.national_number}'
|
||||
|
||||
announce_id = _get_id('announce_id')
|
||||
offer_id = None
|
||||
if announce_id is not None:
|
||||
# passerelle catch DoesNotExist and converts it to 404
|
||||
announce_document = self.announces_documents.get(external_id=f'announce-{announce_id}')
|
||||
offer_id = announce_document.data['offer_id']
|
||||
|
||||
request_data = {
|
||||
'type_de_candidature': post_data.get('type', 'E'),
|
||||
'annonce': _get_id('announce_id'),
|
||||
'annonce': announce_id,
|
||||
'candidature_spontane': 'N' if announce_id else 'O',
|
||||
self.REFERENTIELS_FKEYS['offre']: offer_id,
|
||||
self.REFERENTIELS_FKEYS['civilite']: _get_id('civility'),
|
||||
'firstName': post_data.get('first_name', None),
|
||||
'lastName': post_data.get('last_name', None),
|
||||
|
|
|
@ -299,6 +299,7 @@ class TestEndpoints:
|
|||
assert setof('filiere') == {'', 'FILIERE TECHNIQUE'}
|
||||
assert setof('date') == {'2022-04-11', '2022-04-06', '2022-03-17', '2022-04-19', '2022-04-13'}
|
||||
assert setof('date_fin_publication') == {'2022-05-11', '2022-04-25', '2022-12-31', '2022-04-30'}
|
||||
assert setof('offer_id') == {4005534, 3782130, 3782122, 3450229, 4005526}
|
||||
|
||||
# check html fields
|
||||
assert '<br>Pilotage' in data[0]['description']
|
||||
|
@ -408,56 +409,102 @@ class TestEndpoints:
|
|||
assert response.headers['content-type'] == 'application/pdf'
|
||||
|
||||
def test_create_application(self, resource, app):
|
||||
expected_payload = {
|
||||
'type_de_candidature': 'E',
|
||||
'candidature_spontane': 'O',
|
||||
'R60284409': 170013,
|
||||
'firstName': 'John',
|
||||
'lastName': 'Doe',
|
||||
'sexe': 'H',
|
||||
'date_de_naissance': '1985-03-06',
|
||||
'R1249730': 93421,
|
||||
'date_fin_autorisation_de_travail': '2023-05-09',
|
||||
'rqth': 'N',
|
||||
'date_fin_rqth': '2023-05-08',
|
||||
'permis_de_conduire': 'A,B',
|
||||
'fimo': 'O',
|
||||
'Date_delivrance_fimo': '2023-05-07',
|
||||
'date_fin_validite_fimo': '2023-05-08',
|
||||
'R1258320': 1258319,
|
||||
'collectivite_agent': 'Mairie de Toulouse',
|
||||
'date_debut_disponibilite': '2023-05-02',
|
||||
'date_fin_disponibilite': '2023-05-01',
|
||||
'pretentions_salariales': '1000',
|
||||
'adresse': '12 Sesame Street',
|
||||
'code_postal': '77710',
|
||||
'ville': 'Nemours',
|
||||
'telephone': '+33 636656565',
|
||||
'email': 'csechet@entrouvert.com',
|
||||
'date_debut_contrat': '2023-05-06',
|
||||
'date_fin_contrat': '2023-05-04',
|
||||
'complement_information_candidature': 'I need money.',
|
||||
'R1261279': 1561049,
|
||||
'accord_RGPD': True,
|
||||
'R1249707': [157193, 157194],
|
||||
'R60845221': [5776395, 5776396],
|
||||
'R60845244': [5776394, 5776395],
|
||||
'R15017962': [],
|
||||
'temps_de_travail_souhaite': 'TC',
|
||||
'duree_du_contrat_de_stage_apprentissage': '2h',
|
||||
'ecole_centre_de_formation_mission_loc': 'Ecole de la vie',
|
||||
'intitule_diplome_vise': 'BE',
|
||||
'specialite_diplome': 'Curling',
|
||||
'R1249737': 1124022,
|
||||
'dernier_diplome_obtenu': 'BAC',
|
||||
'derniere_classe_suivie': 'Terminale',
|
||||
}
|
||||
|
||||
application_data = {
|
||||
'additional_informations': 'I need money.',
|
||||
'address': '12 Sesame Street',
|
||||
'address_complement': '',
|
||||
'agent_collectivity': 'Mairie de Toulouse',
|
||||
'aimed_diploma_level': '1124022',
|
||||
'availability_end_date': '2023-05-01',
|
||||
'availability_start_date': '2023-05-02',
|
||||
'birth_date': '1985-03-06',
|
||||
'city': 'Nemours',
|
||||
'civility': '170013',
|
||||
'contract_end_date': '2023-05-04',
|
||||
'contract_start_date': '2023-05-06',
|
||||
'current_situation': '1258319',
|
||||
'desired_work_time': 'TC',
|
||||
'diploma_name': 'BE',
|
||||
'diploma_speciality': 'Curling',
|
||||
'driving_license': 'A,B',
|
||||
'email': 'csechet@entrouvert.com',
|
||||
'fimo': 'o',
|
||||
'fimo_delivrance_date': '2023-05-07',
|
||||
'fimo_end_validity_date': '2023-05-08',
|
||||
'first_name': 'John',
|
||||
'gender': 'H',
|
||||
'internship_duration': '2h',
|
||||
'job_families': ['5776394', '5776395'],
|
||||
'job_realms': ['5776395', '5776396'],
|
||||
'job_types': ['157193', '157194'],
|
||||
'last_course_taken': 'Terminale',
|
||||
'last_name': 'Doe',
|
||||
'last_obtained_diploma': 'BAC',
|
||||
'nationality': '93421',
|
||||
'origin': '1561049',
|
||||
'origin_precisions': '',
|
||||
'phone': '+33 636656565',
|
||||
'rgpd_agreement': 'tRuE',
|
||||
'rqth': False,
|
||||
'rqth_end_date': '2023-05-08',
|
||||
'salary_expectations': '1000',
|
||||
'school_name': 'Ecole de la vie',
|
||||
'type': 'E',
|
||||
'work_authorization_end_date': '2023-05-09',
|
||||
'zip': '77710',
|
||||
}
|
||||
|
||||
@httmock.urlmatch(path=r'^.*/data/candidature$')
|
||||
def handler(url, request):
|
||||
assert request.headers['content-type'] == 'application/json'
|
||||
assert request.headers['api-key'] == APIKEY
|
||||
payload = json.loads(request.body)
|
||||
assert payload == {
|
||||
'type_de_candidature': 'E',
|
||||
'annonce': 524522,
|
||||
'R60284409': 170013,
|
||||
'firstName': 'John',
|
||||
'lastName': 'Doe',
|
||||
'sexe': 'H',
|
||||
'date_de_naissance': '1985-03-06',
|
||||
'R1249730': 93421,
|
||||
'date_fin_autorisation_de_travail': '2023-05-09',
|
||||
'rqth': 'N',
|
||||
'date_fin_rqth': '2023-05-08',
|
||||
'permis_de_conduire': 'A,B',
|
||||
'fimo': 'O',
|
||||
'Date_delivrance_fimo': '2023-05-07',
|
||||
'date_fin_validite_fimo': '2023-05-08',
|
||||
'R1258320': 1258319,
|
||||
'collectivite_agent': 'Mairie de Toulouse',
|
||||
'date_debut_disponibilite': '2023-05-02',
|
||||
'date_fin_disponibilite': '2023-05-01',
|
||||
'pretentions_salariales': '1000',
|
||||
'adresse': '12 Sesame Street',
|
||||
'code_postal': '77710',
|
||||
'ville': 'Nemours',
|
||||
'telephone': '+33 636656565',
|
||||
'email': 'csechet@entrouvert.com',
|
||||
'date_debut_contrat': '2023-05-06',
|
||||
'date_fin_contrat': '2023-05-04',
|
||||
'complement_information_candidature': 'I need money.',
|
||||
'R1261279': 1561049,
|
||||
'accord_RGPD': True,
|
||||
'R1249707': [157193, 157194],
|
||||
'R60845221': [5776395, 5776396],
|
||||
'R60845244': [5776394, 5776395],
|
||||
'R15017962': [],
|
||||
'temps_de_travail_souhaite': 'TC',
|
||||
'duree_du_contrat_de_stage_apprentissage': '2h',
|
||||
'ecole_centre_de_formation_mission_loc': 'Ecole de la vie',
|
||||
'intitule_diplome_vise': 'BE',
|
||||
'specialite_diplome': 'Curling',
|
||||
'R1249737': 1124022,
|
||||
'dernier_diplome_obtenu': 'BAC',
|
||||
'derniere_classe_suivie': 'Terminale',
|
||||
}
|
||||
|
||||
assert payload == expected_payload
|
||||
return httmock.response(200, json.dumps({'code': 200, 'results': [{'id': 42}]}))
|
||||
|
||||
@httmock.urlmatch()
|
||||
|
@ -467,54 +514,31 @@ class TestEndpoints:
|
|||
with httmock.HTTMock(handler, error_handler):
|
||||
response = app.post_json(
|
||||
'/toulouse-foederis/foederis/create-application',
|
||||
params={
|
||||
'additional_informations': 'I need money.',
|
||||
'address': '12 Sesame Street',
|
||||
'address_complement': '',
|
||||
'agent_collectivity': 'Mairie de Toulouse',
|
||||
'aimed_diploma_level': '1124022',
|
||||
'announce_id': '0524522',
|
||||
'availability_end_date': '2023-05-01',
|
||||
'availability_start_date': '2023-05-02',
|
||||
'birth_date': '1985-03-06',
|
||||
'city': 'Nemours',
|
||||
'civility': '170013',
|
||||
'contract_end_date': '2023-05-04',
|
||||
'contract_start_date': '2023-05-06',
|
||||
'current_situation': '1258319',
|
||||
'desired_work_time': 'TC',
|
||||
'diploma_name': 'BE',
|
||||
'diploma_speciality': 'Curling',
|
||||
'driving_license': 'A,B',
|
||||
'email': 'csechet@entrouvert.com',
|
||||
'fimo': 'o',
|
||||
'fimo_delivrance_date': '2023-05-07',
|
||||
'fimo_end_validity_date': '2023-05-08',
|
||||
'first_name': 'John',
|
||||
'gender': 'H',
|
||||
'internship_duration': '2h',
|
||||
'job_families': ['5776394', '5776395'],
|
||||
'job_realms': ['5776395', '5776396'],
|
||||
'job_types': ['157193', '157194'],
|
||||
'last_course_taken': 'Terminale',
|
||||
'last_name': 'Doe',
|
||||
'last_obtained_diploma': 'BAC',
|
||||
'nationality': '93421',
|
||||
'origin': '1561049',
|
||||
'origin_precisions': '',
|
||||
'phone': '+33 636656565',
|
||||
'rgpd_agreement': 'tRuE',
|
||||
'rqth': False,
|
||||
'rqth_end_date': '2023-05-08',
|
||||
'salary_expectations': '1000',
|
||||
'school_name': 'Ecole de la vie',
|
||||
'type': 'E',
|
||||
'work_authorization_end_date': '2023-05-09',
|
||||
'zip': '77710',
|
||||
},
|
||||
params=application_data,
|
||||
)
|
||||
|
||||
assert response.json['data']['application_id'] == 42
|
||||
assert response.json['data']['application_id'] == 42
|
||||
|
||||
announce_id = '9876543'
|
||||
|
||||
response = app.post_json(
|
||||
'/toulouse-foederis/foederis/create-application',
|
||||
params=application_data | {'announce_id': announce_id},
|
||||
status=404,
|
||||
)
|
||||
|
||||
expected_payload.update(
|
||||
{'annonce': int(announce_id), 'candidature_spontane': 'N', 'R14848258': 'ID_OFFRE'}
|
||||
)
|
||||
|
||||
external_id = f'announce-{announce_id}'
|
||||
|
||||
resource.documents.create(external_id=external_id, data={'offer_id': 'ID_OFFRE'})
|
||||
|
||||
response = app.post_json(
|
||||
'/toulouse-foederis/foederis/create-application',
|
||||
params=application_data | {'announce_id': announce_id},
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'phone_number,prefix',
|
||||
|
|
Loading…
Reference in New Issue