Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into github-action-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
MKCG committed Feb 20, 2024
2 parents 12834b4 + 21ef533 commit 1054669
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 4 deletions.
61 changes: 61 additions & 0 deletions aio/aio-proxy/aio_proxy/doc/open-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ paths:
example: "11,76"
schema:
type: string
- name: epci
in: query
description: >-
<a href=https://www.insee.fr/fr/information/2510634>
Liste des epci valides</a>. Ce paramètre filtre sur les
établissements et accepte une valeur unique ou une liste de valeurs
séparées par des virgules.
required: false
example: "200058519,248100737"
schema:
type: string
- name: egapro_renseignee
in: query
description: >-
Expand Down Expand Up @@ -696,6 +707,13 @@ paths:
Date de création de l'établissement (source : base
SIRENE).
example: "2003-01-01"
date_fermeture:
type: string
nullable: true
format: date
description: >-
Date de fermeture de l'établissement (source : base
historique SIRENE).
date_debut_activite:
type: string
format: date
Expand Down Expand Up @@ -869,6 +887,12 @@ paths:
description: >-
Code région de l'établissement (source : base
SIRENE).
epci:
type: string
nullable: true
example: "200058519"
description: >-
Numéro siren de l'EPCI.
siret:
type: string
example: "35600000000048"
Expand All @@ -890,6 +914,12 @@ paths:
example: "1991-01-01"
description: >-
Date de création de l'unité légale (source : base SIRENE).
date_fermeture:
type: string
format: date
description: >-
Date de fermeture de l'unité légale (source : base
historique SIRENE).
tranche_effectif_salarie:
type: string
example: "53"
Expand Down Expand Up @@ -1085,6 +1115,12 @@ paths:
description: >-
Région de l'établissement (source :
base SIRENE).
epci:
type: string
nullable: true
example: "200058519"
description: >-
Numéro siren de l'EPCI.
siret:
type: string
example: "35600000000048"
Expand Down Expand Up @@ -1536,6 +1572,13 @@ paths:
Date de création de l'établissement (source : base
SIRENE).
example: "2003-01-01"
date_fermeture:
type: string
nullable: true
format: date
description: >-
Date de fermeture de l'établissement (source : base
historique SIRENE).
date_debut_activite:
type: string
format: date
Expand Down Expand Up @@ -1708,6 +1751,12 @@ paths:
description: >-
Code région de l'établissement (source : base
SIRENE).
epci:
type: string
nullable: true
example: "200058519"
description: >-
Numéro siren de l'EPCI.
siret:
type: string
example: "35600000000048"
Expand All @@ -1729,6 +1778,12 @@ paths:
example: "1991-01-01"
description: >-
Date de création de l'unité légale (source : base SIRENE).
date_fermeture:
type: string
format: date
description: >-
Date de fermeture de l'unité légale (source : base
historique SIRENE).
tranche_effectif_salarie:
type: string
example: "53"
Expand Down Expand Up @@ -1925,6 +1980,12 @@ paths:
description: >-
Région de l'établissement (source :
base SIRENE).
epci:
type: string
nullable: true
example: "200058519"
description: >-
Numéro siren de l'EPCI.
siret:
type: string
example: "35600000000048"
Expand Down
4 changes: 4 additions & 0 deletions aio/aio-proxy/aio_proxy/request/field_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
"valid_values": r"^((0[1-9])|([1-8][0-9])|(9[0-8])|(2A)|(2B))[0-9]{3}$",
"alias": "activite_principale",
},
"epci": {
"valid_values": r"^\d{9}$",
"alias": "epci",
},
"type_personne": {
"valid_values": ["ELU", "DIRIGEANT"],
"alias": "type_personne",
Expand Down
4 changes: 3 additions & 1 deletion aio/aio-proxy/aio_proxy/request/search_params_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SearchParams(BaseModel):
tranche_effectif_salarie_unite_legale: list | None = None
convention_collective_renseignee: bool | None = None
egapro_renseignee: bool | None = None
epci: list | None = None
est_bio: bool | None = None
est_finess: bool | None = None
est_uai: bool | None = None
Expand Down Expand Up @@ -136,6 +137,7 @@ def make_uppercase(cls, value: str) -> str:
"activite_principale_unite_legale",
"code_collectivite_territoriale",
"commune",
"epci",
"code_postal",
"include",
"include_admin",
Expand All @@ -145,7 +147,7 @@ def convert_str_to_list(cls, str_of_values: str) -> list[str]:
list_of_values = str_to_list(clean_str(str_of_values))
return list_of_values

@field_validator("code_postal", "commune", mode="after")
@field_validator("code_postal", "commune", "epci", mode="after")
def list_of_values_should_match_regular_expression(
cls, list_values: list[str], info
) -> list[str]:
Expand Down
1 change: 1 addition & 0 deletions aio/aio-proxy/aio_proxy/response/format_search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_field(field, default=None):
"caractere_employeur": get_field("caractere_employeur"),
"annee_categorie_entreprise": get_field("annee_categorie_entreprise"),
"date_creation": get_field("date_creation_unite_legale"),
"date_fermeture": get_field("date_fermeture"),
"date_mise_a_jour": get_field("date_mise_a_jour"),
"date_mise_a_jour_insee": get_field("date_mise_a_jour_insee"),
"date_mise_a_jour_rne": get_field("date_mise_a_jour_rne"),
Expand Down
6 changes: 4 additions & 2 deletions aio/aio-proxy/aio_proxy/response/formatters/etablissements.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ def get_field(field, default=None):
"coordonnees": get_field("coordonnees"),
"date_creation": get_field("date_creation"),
"date_debut_activite": get_field("date_debut_activite"),
"date_fermeture": get_field("date_fermeture"),
"date_mise_a_jour": None,
"date_mise_a_jour_insee": get_field("date_mise_a_jour_insee"),
"departement": get_field("departement"),
"distribution_speciale": get_field("distribution_speciale"),
"epci": get_field("epci"),
"est_siege": get_field("est_siege", False),
"etat_administratif": get_field("etat_administratif"),
"geo_adresse": get_field("geo_adresse"),
Expand Down Expand Up @@ -83,6 +85,8 @@ def format_etablissements_list(etablissements=None):
"cedex",
"code_pays_etranger",
"complement_adresse",
"date_mise_a_jour",
"date_mise_a_jour_insee",
"departement",
"distribution_speciale",
"geo_adresse",
Expand All @@ -93,8 +97,6 @@ def format_etablissements_list(etablissements=None):
"libelle_voie",
"numero_voie",
"type_voie",
"date_mise_a_jour",
"date_mise_a_jour_insee",
]
etablissements_formatted = []
if etablissements:
Expand Down
3 changes: 3 additions & 0 deletions aio/aio-proxy/aio_proxy/response/unite_legale_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ class Etablissement(BaseModel):
coordonnees: str | None = None
date_creation: str | None = None
date_debut_activite: str | None = None
date_fermeture: str | None = None
date_mise_a_jour: str | None = None
date_mise_a_jour_insee: str | None = None
departement: str | None = None
distribution_speciale: str | None = None
epci: str | None = None
est_siege: bool = False
etat_administratif: str | None = None
geo_adresse: str | None = None
Expand Down Expand Up @@ -121,6 +123,7 @@ class UniteLegaleResponse(BaseModel):
caractere_employeur: str | None = None
annee_categorie_entreprise: str | None = None
date_creation: str | None = None
date_fermeture: str | None = None
date_mise_a_jour: str | None = None
date_mise_a_jour_insee: str | None = None
date_mise_a_jour_rne: str | None = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def build_etablissements_filters(search_params):
# Id filters are used in the `should` clause
id_filters = ["id_finess", "id_rge", "id_uai", "id_convention_collective"]
# Text filters are used in the `must` clause
text_filters = ["departement", "code_postal", "commune", "region"]
text_filters = ["departement", "code_postal", "commune", "epci", "region"]
# Bool filters are used in both `must` and `must_not` clauses depending on the
# filter value
bool_filters = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def is_any_etablissement_filter_used(search_params) -> bool:
"code_postal",
"convention_collective_renseignee",
"departement",
"epci",
"est_bio",
"est_finess",
"est_organisme_formation",
Expand Down
10 changes: 10 additions & 0 deletions aio/aio-proxy/aio_proxy/tests/e2e_tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,13 @@ def test_siren_rne_and_insee(api_response_tester):
api_response_tester.assert_api_response_code_200(path)
assert response.json()["results"][0]["date_mise_a_jour_rne"] is not None
assert response.json()["results"][0]["date_mise_a_jour_insee"] is not None


def test_epci(api_response_tester):
path = "search?epci=248100737"
response = api_response_tester.get_api_response(path)
api_response_tester.assert_api_response_code_200(path)
assert (
response.json()["results"][0]["matching_etablissements"][0]["epci"]
== "248100737"
)

0 comments on commit 1054669

Please sign in to comment.