Skip to content

Commit

Permalink
[BUG]fix: get nom commercial in case of missing siege
Browse files Browse the repository at this point in the history
Merge pull request #404 from annuaire-entreprises-data-gouv-fr/fix-nom-commercial
  • Loading branch information
HAEKADI authored Aug 13, 2024
2 parents 8dbc4bf + 40bb6e7 commit 8c487ca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions aio/aio-proxy/aio_proxy/response/format_search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
)
from aio_proxy.response.formatters.immatriculation import format_immatriculation
from aio_proxy.response.formatters.nature_juridique import format_nature_juridique
from aio_proxy.response.formatters.nom_complet import format_nom_complet
from aio_proxy.response.formatters.nom_complet import (
format_nom_complet,
get_nom_commercial,
)
from aio_proxy.response.formatters.non_diffusible import (
hide_non_diffusible_fields,
)
Expand Down Expand Up @@ -36,7 +39,7 @@ def get_field(field, default=None):
"nom_complet": format_nom_complet(
get_field("nom_complet"),
get_field("sigle"),
get_field("siege")["nom_commercial"],
get_nom_commercial(get_field("siege")),
get_field("denomination_usuelle_1_unite_legale"),
get_field("denomination_usuelle_2_unite_legale"),
get_field("denomination_usuelle_3_unite_legale"),
Expand Down
4 changes: 4 additions & 0 deletions aio/aio-proxy/aio_proxy/response/formatters/nom_complet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
def get_nom_commercial(siege):
return siege.get("nom_commercial", None) if siege else None


def format_nom_complet(
nom_complet,
sigle=None,
Expand Down
7 changes: 7 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 @@ -754,3 +754,10 @@ def test_immatriculation(api_response_tester):
api_response_tester.test_field_value(
path_gan, 0, f"immatriculation.{field}", expected_value
)


def test_ul_sans_siege(api_response_tester):
path = "search?q=006178073"
api_response_tester.assert_api_response_code_200(path)
api_response_tester.test_number_of_results(path, 1)
api_response_tester.test_field_value(path, 0, "siege", {})

0 comments on commit 8c487ca

Please sign in to comment.