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 df70e98 commit 35e63b2
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 0 deletions.
69 changes: 69 additions & 0 deletions pipeline/dbt/models/intermediate/_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,72 @@ unit_tests:
- {adresse_id: changed-code-insee}
- {adresse_id: changed-commune}
- {adresse_id: new}

- name: test_zone_diffusion_is_correctly_filled
model: int__union_services__enhanced
overrides:
macros:
dbt_utils.star: |
services._di_surrogate_id,
services._di_adresse_surrogate_id,
services._di_structure_surrogate_id,
services.id,
services.structure_id,
services.nom,
services.source,
services.zone_diffusion_type,
services.contact_public,
services.contact_nom_prenom,
services.courriel,
services.cumulable,
services.date_creation,
services.date_suspension,
services.frais,
services.frais_autres,
services.justificatifs,
services.lien_source,
services.modes_accueil,
services.modes_orientation_accompagnateur,
services.modes_orientation_accompagnateur_autres,
services.modes_orientation_beneficiaire,
services.modes_orientation_beneficiaire_autres,
services.page_web,
services.presentation_detail,
services.presentation_resume,
services.prise_rdv,
services.profils,
services.recurrence,
services.telephone,
services.thematiques,
services.types,
services.pre_requis,
services.date_maj
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'}
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

0 comments on commit 35e63b2

Please sign in to comment.