Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
FakeDataInclusionClient: utilisation mapping thematiques
Browse files Browse the repository at this point in the history
  • Loading branch information
ggounot committed Oct 2, 2024
1 parent dd02bb3 commit ae54de4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion dora/data_inclusion/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Optional
from uuid import uuid4

from .constants import THEMATIQUES_MAPPING_DORA_TO_DI


def make_di_service_data(**kwargs) -> dict:
return {
Expand Down Expand Up @@ -99,13 +101,18 @@ def search_services(
services = [r for r in services if r["source"] in sources]

if thematiques is not None:
enriched_thematiques = []
for thematique in thematiques:
enriched_thematiques += THEMATIQUES_MAPPING_DORA_TO_DI.get(
thematique, [thematique]
)
services = [
r
for r in services
if any(
t.startswith(requested_thematique)
for t in r["thematiques"]
for requested_thematique in thematiques
for requested_thematique in enriched_thematiques
)
]

Expand Down
4 changes: 2 additions & 2 deletions dora/data_inclusion/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ def test_map_service_thematiques_mapping():
di_service_data = make_di_service_data(thematiques=input_thematiques)
service = map_service(di_service_data, False)

assert set(service["categories"]) == set(expected_categories)
assert set(service["subcategories"]) == set(expected_subcategories)
assert sorted(service["categories"]) == sorted(expected_categories)
assert sorted(service["subcategories"]) == sorted(expected_subcategories)

0 comments on commit ae54de4

Please sign in to comment.