This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correspondance schéma d·i - profils et besoins pour thématiques logem…
…ent-hebergement (#393) Correspondance de thématiques dans les deux sens via les constantes `THEMATIQUES_MAPPING_DI_TO_DORA` et `THEMATIQUES_MAPPING_DORA_TO_DI`. Utilisation par `map_service()`, `DataInclusionClient.search_services()` et `FakeDataInclusionClient.search_services()`. Ajout de tests.
- Loading branch information
Showing
5 changed files
with
75 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from collections import defaultdict | ||
|
||
# À une thématique DI correspond une thématique Dora | ||
THEMATIQUES_MAPPING_DI_TO_DORA = { | ||
"logement-hebergement--etre-accompagne-dans-son-projet-accession": "logement-hebergement--etre-accompagne-pour-se-loger", | ||
"logement-hebergement--etre-accompagne-en cas-de-difficultes-financieres": "logement-hebergement--gerer-son-budget", | ||
"logement-hebergement--financer-son-projet-travaux": "logement-hebergement--autre", | ||
} | ||
|
||
# Inversion du dictionnaire | ||
# À une thématique Dora correspond une liste de thématiques DI | ||
THEMATIQUES_MAPPING_DORA_TO_DI = defaultdict(list) | ||
for key, value in THEMATIQUES_MAPPING_DI_TO_DORA.items(): | ||
if not value.endswith("--autre"): | ||
THEMATIQUES_MAPPING_DORA_TO_DI[value].append(key) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from .constants import THEMATIQUES_MAPPING_DI_TO_DORA, THEMATIQUES_MAPPING_DORA_TO_DI | ||
from .mappings import map_service | ||
from .test_utils import FakeDataInclusionClient, make_di_service_data | ||
|
||
|
||
def test_map_service_thematiques_mapping(): | ||
input_thematiques = [ | ||
"logement-hebergement", | ||
"logement-hebergement--connaissance-de-ses-droits-et-interlocuteurs", | ||
"logement-hebergement--besoin-dadapter-mon-logement", | ||
] + list(THEMATIQUES_MAPPING_DI_TO_DORA.keys()) | ||
|
||
expected_categories = ["logement-hebergement"] | ||
expected_subcategories = [ | ||
"logement-hebergement--connaissance-de-ses-droits-et-interlocuteurs", | ||
"logement-hebergement--besoin-dadapter-mon-logement", | ||
] + list(THEMATIQUES_MAPPING_DI_TO_DORA.values()) | ||
|
||
di_service_data = make_di_service_data(thematiques=input_thematiques) | ||
service = map_service(di_service_data, False) | ||
|
||
assert sorted(service["categories"]) == sorted(expected_categories) | ||
assert sorted(service["subcategories"]) == sorted(expected_subcategories) | ||
|
||
|
||
def test_di_client_search_thematiques_mapping(): | ||
input_thematique = list(THEMATIQUES_MAPPING_DORA_TO_DI.keys())[0] | ||
output_thematique = list(THEMATIQUES_MAPPING_DORA_TO_DI.values())[0][0] | ||
|
||
di_client = FakeDataInclusionClient() | ||
di_service_data = make_di_service_data(thematiques=[output_thematique]) | ||
di_client.services.append(di_service_data) | ||
|
||
results = di_client.search_services(thematiques=[input_thematique]) | ||
|
||
assert len(results) == 1 |