-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FT): add horaires in open street map format
- Loading branch information
Showing
5 changed files
with
267 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
pipeline/tests/unit/test_format_date_ft_to_open_street_map.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
from dags.dag_utils.sources.france_travail import format_date_ft_to_open_street_map | ||
|
||
|
||
def test_horaires_continus(): | ||
horaires = [ | ||
{ | ||
"jour": 1, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "O", | ||
"ouvertureMatin": "08:00", | ||
"fermetureApresMidi": "18:00", | ||
} | ||
] | ||
assert format_date_ft_to_open_street_map(horaires) == "Mo 08:00-18:00; PH off" | ||
|
||
|
||
def test_horaires_non_continus_sans_apres_midi(): | ||
horaires = [ | ||
{ | ||
"jour": 2, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "N", | ||
"ouvertureMatin": "09:00", | ||
"fermetureMatin": "12:00", | ||
} | ||
] | ||
assert format_date_ft_to_open_street_map(horaires) == "Tu 09:00-12:00; PH off" | ||
|
||
|
||
def test_deux_jours(): | ||
horaires = [ | ||
{ | ||
"jour": 1, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "O", | ||
"ouvertureMatin": "08:00", | ||
"fermetureApresMidi": "18:00", | ||
}, | ||
{ | ||
"jour": 2, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "N", | ||
"ouvertureMatin": "09:00", | ||
"fermetureMatin": "12:00", | ||
}, | ||
] | ||
assert ( | ||
format_date_ft_to_open_street_map(horaires) | ||
== "Mo 08:00-18:00;Tu 09:00-12:00; PH off" | ||
) | ||
|
||
|
||
def test_horaires_non_continus_sans_matin(): | ||
horaires = [ | ||
{ | ||
"jour": 3, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "N", | ||
"ouvertureApresMidi": "14:00", | ||
"fermetureApresMidi": "17:00", | ||
} | ||
] | ||
assert format_date_ft_to_open_street_map(horaires) == "We 14:00-17:00; PH off" | ||
|
||
|
||
def test_horaires_non_continus_complets(): | ||
horaires = [ | ||
{ | ||
"jour": 4, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "N", | ||
"ouvertureMatin": "09:00", | ||
"fermetureMatin": "12:00", | ||
"ouvertureApresMidi": "14:00", | ||
"fermetureApresMidi": "17:00", | ||
} | ||
] | ||
assert ( | ||
format_date_ft_to_open_street_map(horaires) | ||
== "Th 09:00-12:00,14:00-17:00; PH off" | ||
) | ||
|
||
|
||
def test_jour_ferme_seul(): | ||
horaires = [{"jour": 4, "horaireFerme": "O"}] | ||
assert format_date_ft_to_open_street_map(horaires) is None | ||
|
||
|
||
def test_jour_ferme(): | ||
horaires = [ | ||
{"jour": 4, "horaireFerme": "O"}, | ||
{ | ||
"jour": 5, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "N", | ||
"ouvertureMatin": "09:00", | ||
"fermetureMatin": "12:00", | ||
}, | ||
] | ||
assert format_date_ft_to_open_street_map(horaires) == "Fr 09:00-12:00; PH off" | ||
|
||
|
||
def test_dictionnaire_vide(): | ||
horaires = [] | ||
assert format_date_ft_to_open_street_map(horaires) is None | ||
|
||
|
||
def test_format_uniforme_tous_les_jours(): | ||
horaires = [ | ||
{ | ||
"jour": 1, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "O", | ||
"ouvertureMatin": "08:00", | ||
"fermetureApresMidi": "18:00", | ||
}, | ||
{ | ||
"jour": 2, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "O", | ||
"ouvertureMatin": "08:00", | ||
"fermetureApresMidi": "18:00", | ||
}, | ||
{ | ||
"jour": 3, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "O", | ||
"ouvertureMatin": "08:00", | ||
"fermetureApresMidi": "18:00", | ||
}, | ||
{ | ||
"jour": 4, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "O", | ||
"ouvertureMatin": "08:00", | ||
"fermetureApresMidi": "18:00", | ||
}, | ||
{ | ||
"jour": 5, | ||
"horaireFerme": "N", | ||
"horaireEnContinu": "O", | ||
"ouvertureMatin": "08:00", | ||
"fermetureApresMidi": "18:00", | ||
}, | ||
] | ||
assert format_date_ft_to_open_street_map(horaires) == "Mo-Fr 08:00-18:00; PH off" | ||
|
||
|
||
def test_horaires_vide(): | ||
horaires = [] | ||
assert format_date_ft_to_open_street_map(horaires) is None | ||
|
||
|
||
def test_horaires_none(): | ||
horaires = None | ||
assert format_date_ft_to_open_street_map(horaires) is None |