Skip to content

Commit

Permalink
chore(api):remove sources filter on structures
Browse files Browse the repository at this point in the history
chore(api): remove source filtrer from structure (test)
  • Loading branch information
YannickPassa committed Nov 12, 2024
1 parent b768303 commit 46acdc3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 62 deletions.
17 changes: 0 additions & 17 deletions api/src/data_inclusion/api/inclusion_data/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down Expand Up @@ -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:
Expand All @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions api/src/data_inclusion/api/inclusion_data/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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_)

Expand Down Expand Up @@ -220,7 +216,6 @@ def list_structures(
query = filter_structures_by_thematiques(query, thematiques)

query = query.order_by(
models.Structure.source,
models.Structure.id,
)

Expand Down
14 changes: 0 additions & 14 deletions api/tests/e2e/api/__snapshots__/test_inclusion_data.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
50 changes: 24 additions & 26 deletions api/tests/e2e/api/test_inclusion_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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/"

Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 46acdc3

Please sign in to comment.