Skip to content

Commit

Permalink
__wip : test unitaire
Browse files Browse the repository at this point in the history
  • Loading branch information
vperron committed Sep 18, 2024
1 parent 63cec32 commit a95c124
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pipeline/dbt/models/intermediate/_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,39 @@ models:
* geocoded addresses
* email with pii flag
unit_tests:
- name: test_zone_diffusion_is_correctly_filled
model: int__union_services__enhanced
overrides:
macros:
dbt_utils.star: '*'
given:
- input: ref('stg_decoupage_administratif__departements')
rows:
- {code: '75', nom: 'Paris'}
- {code: '974', nom: 'La Réunion'}
- input: ref('int__union_structures__enhanced')
format: sql
rows:
select '1' as _di_surrogate_id, 'monenfant' as source, '22 rue Sainte-Marthe' as adresse
union all
select '2' as _di_surrogate_id, 'soliguide' as source, '3 Rpe des Mobiles' as adresse
union all
select '3' as _di_surrogate_id, 'dora' as source, null as adresse
- input: ref('int__union_adresses__enhanced')
rows:
- {_di_surrogate_id: '1', code_insee: '75101'}
- {_di_surrogate_id: '2', code_insee: '97423'}
- {_di_surrogate_id: '3', code_insee: null}
- input: ref('int__union_services')
format: sql
fixture: zone_diffusion_services
expect:
rows:
- {adresse: '22 rue Sainte-Marthe'}
- {adresse: '3 Rpe des Mobiles'}
- {adresse: null}
- {adresse: null}
- {adresse: '36 Rte de Toulon'}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,victor,W,18.09.2024 15:03,file:///home/victor/.config/libreoffice/4;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,victor,W,18.09.2024 15:03,file:///home/victor/.config/libreoffice/4;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,victor,W,18.09.2024 15:03,file:///home/victor/.config/libreoffice/4;
4 changes: 4 additions & 0 deletions pipeline/dbt/tests/fixtures/zone_diffusion_adresses.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_di_surrogate_id,id,source,complement_adresse,adresse,longitude,latitude,commune,code_postal,code_insee,result_score
1,1,dora,VILTAIS ACCUEIL LOGEMENT,8 Rue Ernest Montuses,2.618378,46.324104,Montluçon,3100,3185,0.968204545454545
2,2,dora,,18 Rue Charles Baudelaire,3.906533,50.257305,Hautmont,59330,59291,0.960154545454545
3,3,mediation-numerique,,8 Grand Rue,-0.74859,46.923074,Mauléon,79700,79079,0.965628181818182
113 changes: 113 additions & 0 deletions pipeline/dbt/tests/fixtures/zone_diffusion_services.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
select
'1' as _di_surrogate_id,
'1' as _di_adresse_surrogate_id,
'1' as _di_structure_surrogate_id,
'1' as id,
'1' as structure_id,
'Mon premier service' as nom,
'monenfant' as source,
'75101' as zone_diffusion_code,
'commune' as zone_diffusion_type,
'Paris' as zone_diffusion_nom,
true as contact_public,
'Jean Mermoz' as contact_nom_prenom,
'[email protected]' as courriel,
true as cumulable,
NULL as date_creation,
NULL as date_suspension,
NULL as frais,
NULL as frais_autres,
NULL as justificatifs,
NULL as lien_source,
NULL as modes_accueil,
NULL as modes_orientation_accompagnateur,
NULL as modes_orientation_accompagnateur_autres,
NULL as modes_orientation_beneficiaire,
NULL as modes_orientation_beneficiaire_autres,
NULL as page_web,
NULL as presentation_detail,
NULL as presentation_resume,
NULL as prise_rdv,
NULL as profils,
NULL as recurrence,
NULL as telephone,
NULL as thematiques,
NULL as types,
NULL as pre_requis,
CURRENT_DATE as date_maj
union all
select
'2' as _di_surrogate_id,
'2' as _di_adresse_surrogate_id,
'2' as _di_structure_surrogate_id,
'2' as id,
'2' as structure_id,
'Un super service' as nom,
'soliguide' as source,
'97423' as zone_diffusion_code,
'commune' as zone_diffusion_type,
'La Réunion' as zone_diffusion_nom,
true as contact_public,
'Léa Salami' as contact_nom_prenom,
'[email protected]' as courriel,
true as cumulable,
NULL as date_creation,
NULL as date_suspension,
NULL as frais,
NULL as frais_autres,
NULL as justificatifs,
NULL as lien_source,
NULL as modes_accueil,
NULL as modes_orientation_accompagnateur,
NULL as modes_orientation_accompagnateur_autres,
NULL as modes_orientation_beneficiaire,
NULL as modes_orientation_beneficiaire_autres,
NULL as page_web,
NULL as presentation_detail,
NULL as presentation_resume,
NULL as prise_rdv,
NULL as profils,
NULL as recurrence,
NULL as telephone,
NULL as thematiques,
NULL as types,
NULL as pre_requis,
CURRENT_DATE as date_maj
union all
select
'3' as _di_surrogate_id,
'3' as _di_adresse_surrogate_id,
'3' as _di_structure_surrogate_id,
'3' as id,
'3' as structure_id,
'Mon dernier service' as nom,
'dora' as source,
'974' as zone_diffusion_code,
'departement' as zone_diffusion_type,
'La Réunion' as zone_diffusion_nom,
true as contact_public,
NULL as contact_nom_prenom,
NULL as courriel,
false as cumulable,
NULL as date_creation,
NULL as date_suspension,
NULL as frais,
NULL as frais_autres,
NULL as justificatifs,
NULL as lien_source,
NULL as modes_accueil,
NULL as modes_orientation_accompagnateur,
NULL as modes_orientation_accompagnateur_autres,
NULL as modes_orientation_beneficiaire,
NULL as modes_orientation_beneficiaire_autres,
NULL as page_web,
NULL as presentation_detail,
NULL as presentation_resume,
NULL as prise_rdv,
NULL as profils,
NULL as recurrence,
NULL as telephone,
NULL as thematiques,
NULL as types,
NULL as pre_requis,
CURRENT_DATE as date_maj
4 changes: 4 additions & 0 deletions pipeline/dbt/tests/fixtures/zone_diffusion_structures.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessibilite,adresse_id,antenne,courriel,horaires_ouverture,id,labels_autres,labels_nationaux,lien_source,nom,presentation_detail,presentation_resume,rna,siret,site_web,source,telephone,typologie,date_maj,thematiques,_di_surrogate_id,_di_adresse_surrogate_id,longitude,latitude,complement_adresse,commune,adresse,code_postal,code_insee,_di_geocodage_score,_di_email_is_pii
,1,f,,,1,{},{conseiller-numerique},https://dora.inclusion.beta.gouv.fr/structures/le-mans-metropole-co,LE MANS METROPOLE COMMUNAUTE URBAINE,,,,24720013200014,,dora,,,2022-09-29,,1,1,0.19695,48.007479,1 - 2,Le Mans,1 PL SAINT PIERRE,72039,72181,,f
https://www.pole-emploi.fr/actualites/a-laffiche/2022/adeda-un-dispositif-pour-mieux-a.html,2,f,,,2,,{france-travail},,Agence France Travail CHARLEVILLE-MEZIERES VAL DE VENCE,,,,13000548120281,https://www.francetravail.fr,france-travail,3949,FT,2024-09-17,,2,2,4.729209,49.742055,,Charleville-Mézières,6 Rue Jean-baptiste Lefort,8000,8105,0.966555454545454,f
,3,,,,3,{ZRR},{conseiller-numerique},,Médiathèque du Haut-Verdon,,,,,https://www.ccapv.fr/services-publics/france-services/conseils-numeriques,mediation-numerique,,BIB,2024-06-27,"{numerique,numerique--prendre-en-main-un-smartphone-ou-une-tablette,numerique--prendre-en-main-un-ordinateur,numerique--utiliser-le-numerique-au-quotidien,numerique--approfondir-ma-culture-numerique,numerique--accompagner-les-demarches-de-sante}",3,3,6.628006,44.240556,,Allos,Grand Rue,4260,4006,0.951707272727273,f

0 comments on commit a95c124

Please sign in to comment.