From 46acdc39476e0be7f00b3c83f997b903c8ef6129 Mon Sep 17 00:00:00 2001 From: Yannick Passarelli Date: Thu, 31 Oct 2024 21:56:12 +0100 Subject: [PATCH] chore(api):remove sources filter on structures chore(api): remove source filtrer from structure (test) --- .../api/inclusion_data/routes.py | 17 ------- .../api/inclusion_data/services.py | 5 -- .../__snapshots__/test_inclusion_data.ambr | 14 ------ api/tests/e2e/api/test_inclusion_data.py | 50 +++++++++---------- 4 files changed, 24 insertions(+), 62 deletions(-) diff --git a/api/src/data_inclusion/api/inclusion_data/routes.py b/api/src/data_inclusion/api/inclusion_data/routes.py index c97c27ad..5d668e0e 100644 --- a/api/src/data_inclusion/api/inclusion_data/routes.py +++ b/api/src/data_inclusion/api/inclusion_data/routes.py @@ -54,19 +54,6 @@ ) def list_structures_endpoint( request: fastapi.Request, - source: Annotated[ - Optional[str], - fastapi.Query(include_in_schema=False), - ] = None, - sources: Annotated[ - Optional[list[str]], - fastapi.Query( - description="""Une liste d'identifiants de source. - La liste des identifiants de source est disponible sur le endpoint - dédié. Les résultats seront limités aux sources spécifiées. - """, - ), - ] = None, id: Annotated[Optional[str], fastapi.Query(include_in_schema=False)] = None, typologie: Annotated[Optional[di_schema.Typologie], fastapi.Query()] = None, label_national: Annotated[ @@ -94,9 +81,6 @@ def list_structures_endpoint( code_commune: CodeCommuneFilter = None, db_session=fastapi.Depends(db.get_session), ): - if sources is None and source is not None: - sources = [source] - region = get_region_by_code_or_slug(code=code_region, slug=slug_region) if code_departement is None and departement is not None: @@ -111,7 +95,6 @@ def list_structures_endpoint( return services.list_structures( request, db_session, - sources=sources, id_=id, typologie=typologie, label_national=label_national, diff --git a/api/src/data_inclusion/api/inclusion_data/services.py b/api/src/data_inclusion/api/inclusion_data/services.py index 2c91b660..173bbd5d 100644 --- a/api/src/data_inclusion/api/inclusion_data/services.py +++ b/api/src/data_inclusion/api/inclusion_data/services.py @@ -178,7 +178,6 @@ def filter_restricted( def list_structures( request: fastapi.Request, db_session: orm.Session, - sources: list[str] | None = None, id_: str | None = None, typologie: di_schema.Typologie | None = None, label_national: di_schema.LabelNational | None = None, @@ -190,9 +189,6 @@ def list_structures( query = sqla.select(models.Structure) query = filter_restricted(query, request) - if sources is not None: - query = filter_by_sources(query, sources) - if id_ is not None: query = query.filter_by(id=id_) @@ -220,7 +216,6 @@ def list_structures( query = filter_structures_by_thematiques(query, thematiques) query = query.order_by( - models.Structure.source, models.Structure.id, ) diff --git a/api/tests/e2e/api/__snapshots__/test_inclusion_data.ambr b/api/tests/e2e/api/__snapshots__/test_inclusion_data.ambr index 2ad666ba..0ca8ded3 100644 --- a/api/tests/e2e/api/__snapshots__/test_inclusion_data.ambr +++ b/api/tests/e2e/api/__snapshots__/test_inclusion_data.ambr @@ -33,20 +33,6 @@ } ], "parameters": [ - { - "name": "sources", - "in": "query", - "required": false, - "schema": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Une liste d'identifiants de source.\n La liste des identifiants de source est disponible sur le endpoint\n dédié. Les résultats seront limités aux sources spécifiées.\n ", - "title": "Sources" - }, - "description": "Une liste d'identifiants de source.\n La liste des identifiants de source est disponible sur le endpoint\n dédié. Les résultats seront limités aux sources spécifiées.\n " - }, { "name": "typologie", "in": "query", diff --git a/api/tests/e2e/api/test_inclusion_data.py b/api/tests/e2e/api/test_inclusion_data.py index e070bdfc..e8559226 100644 --- a/api/tests/e2e/api/test_inclusion_data.py +++ b/api/tests/e2e/api/test_inclusion_data.py @@ -176,21 +176,21 @@ def test_list_structures_filter_by_label( assert_paginated_response_data(response.json(), total=0) -@pytest.mark.with_token -@pytest.mark.feature_deprecated -def test_list_structures_filter_by_source(api_client): - structure_1 = factories.StructureFactory(source="emplois-de-linclusion") - factories.StructureFactory(source="dora") +# @pytest.mark.with_token +# @pytest.mark.feature_deprecated +# def test_list_structures_filter_by_source(api_client): +# structure_1 = factories.StructureFactory(source="emplois-de-linclusion") +# factories.StructureFactory(source="dora") - url = "/api/v0/structures/" - response = api_client.get(url, params={"source": "emplois-de-linclusion"}) +# url = "/api/v0/structures/" +# response = api_client.get(url, params={"source": "emplois-de-linclusion"}) - resp_data = response.json() - assert_paginated_response_data(response.json(), total=1) - assert_structure_data(structure_1, resp_data["items"][0]) +# resp_data = response.json() +# assert_paginated_response_data(response.json(), total=1) +# assert_structure_data(structure_1, resp_data["items"][0]) - response = api_client.get(url, params={"source": "siao"}) - assert_paginated_response_data(response.json(), total=0) +# response = api_client.get(url, params={"source": "siao"}) +# assert_paginated_response_data(response.json(), total=0) @pytest.mark.with_token @@ -220,21 +220,20 @@ def test_list_sources(api_client): @pytest.mark.with_token @pytest.mark.feature_deprecated -def test_list_structures_filter_by_source_and_id( +def test_list_structures_filter_by_id( api_client, ): - factories.StructureFactory(source="emplois-de-linclusion", id="foo") - structure_2 = factories.StructureFactory(source="dora", id="foo") - factories.StructureFactory(source="dora", id="bar") + structure_1 = factories.StructureFactory(id="foo") + # structure_2 = factories.StructureFactory(id="foo") + factories.StructureFactory(id="bar") url = "/api/v0/structures/" - response = api_client.get(url, params={"source": "dora", "id": "foo"}) + response = api_client.get(url, params={"id": "foo"}) resp_data = response.json() - resp_data = response.json() assert_paginated_response_data(response.json(), total=1) - assert_structure_data(structure_2, resp_data["items"][0]) + assert_structure_data(structure_1, resp_data["items"][0]) def test_list_services_unauthenticated(api_client): @@ -311,9 +310,9 @@ def test_list_services_all(api_client): def test_list_structures_order( api_client, ): - structure_1 = factories.StructureFactory(source="alpha", id="2") - structure_2 = factories.StructureFactory(source="beta", id="1") - structure_3 = factories.StructureFactory(source="alpha", id="1") + structure_1 = factories.StructureFactory(id="2") + structure_2 = factories.StructureFactory(id="1") + structure_3 = factories.StructureFactory(id="1") url = "/api/v0/structures/" @@ -323,9 +322,9 @@ def test_list_structures_order( resp_data = response.json() - assert resp_data["items"][0]["id"] == structure_3.id - assert resp_data["items"][1]["id"] == structure_1.id - assert resp_data["items"][2]["id"] == structure_2.id + assert resp_data["items"][0]["id"] == structure_2.id + assert resp_data["items"][1]["id"] == structure_3.id + assert resp_data["items"][2]["id"] == structure_1.id @pytest.mark.with_token @@ -802,7 +801,6 @@ def test_can_filter_services_by_modes_accueil(api_client, url): [ ("/api/v0/services", factories.ServiceFactory), ("/api/v0/search/services", factories.ServiceFactory), - ("/api/v0/structures", factories.StructureFactory), ], ) def test_can_filter_resources_by_sources(api_client, url, factory):