Ajout du lien observatoire dans acheteur_nom via add_links() #65
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-9
@@ -80,15 +80,21 @@ def add_links(dff: pl.DataFrame):
|
|||||||
.alias(col)
|
.alias(col)
|
||||||
)
|
)
|
||||||
if col.startswith("acheteur_"):
|
if col.startswith("acheteur_"):
|
||||||
dff = dff.with_columns(
|
detail_link = (
|
||||||
(
|
'<a href = "/acheteurs/'
|
||||||
'<a href = "/acheteurs/'
|
+ pl.col("acheteur_id")
|
||||||
+ pl.col("acheteur_id")
|
+ '">'
|
||||||
+ '">'
|
+ pl.col(col)
|
||||||
+ pl.col(col)
|
+ "</a>"
|
||||||
+ "</a>"
|
|
||||||
).alias(col)
|
|
||||||
)
|
)
|
||||||
|
if col == "acheteur_nom":
|
||||||
|
detail_link = (
|
||||||
|
detail_link
|
||||||
|
+ ' <a href="/observatoire?acheteur_id='
|
||||||
|
+ pl.col("acheteur_id")
|
||||||
|
+ '" title="Voir dans l\'observatoire">📊</a>'
|
||||||
|
)
|
||||||
|
dff = dff.with_columns(detail_link.alias(col))
|
||||||
if col == "uid":
|
if col == "uid":
|
||||||
dff = dff.with_columns(
|
dff = dff.with_columns(
|
||||||
(
|
(
|
||||||
@@ -648,7 +654,7 @@ def prepare_table_data(
|
|||||||
# Remplace les strings null par "", mais pas les numeric null
|
# Remplace les strings null par "", mais pas les numeric null
|
||||||
dff = dff.fill_null("")
|
dff = dff.fill_null("")
|
||||||
|
|
||||||
# Ajout des liens vers l'annuaire des entreprises
|
# Ajout des liens vers les pages de détails
|
||||||
dff = add_links(dff)
|
dff = add_links(dff)
|
||||||
|
|
||||||
# Ajout des liens vers les fichiers Open Data
|
# Ajout des liens vers les fichiers Open Data
|
||||||
|
|||||||
+30
-6
@@ -29,12 +29,11 @@ def test_001_logo_and_search(dash_duo: DashComposite):
|
|||||||
assert len(result_table.find_elements(by=By.TAG_NAME, value="tr")) == 2, (
|
assert len(result_table.find_elements(by=By.TAG_NAME, value="tr")) == 2, (
|
||||||
"The search should return only one result"
|
"The search should return only one result"
|
||||||
) # header row + 1 result
|
) # header row + 1 result
|
||||||
assert (
|
assert result_table.find_element(
|
||||||
result_table.find_element(
|
by=By.CSS_SELECTOR, value=f'td[data-dash-column="{org_type}_nom"]'
|
||||||
by=By.CSS_SELECTOR, value=f'td[data-dash-column="{org_type}_nom"]'
|
).text.startswith(name), (
|
||||||
).text
|
f"The search result should have the right {org_type} name"
|
||||||
== name
|
)
|
||||||
), f"The search result should have the right {org_type} name"
|
|
||||||
|
|
||||||
|
|
||||||
def test_002_filter_persistence(dash_duo: DashComposite):
|
def test_002_filter_persistence(dash_duo: DashComposite):
|
||||||
@@ -87,3 +86,28 @@ def test_003_tableau_download(dash_duo: DashComposite):
|
|||||||
)
|
)
|
||||||
assert output["type"] is None
|
assert output["type"] is None
|
||||||
assert output["base64"] is True
|
assert output["base64"] is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_004_add_links_observatoire_acheteur():
|
||||||
|
import polars as pl
|
||||||
|
|
||||||
|
from src.utils import add_links
|
||||||
|
|
||||||
|
dff = pl.DataFrame(
|
||||||
|
{
|
||||||
|
"acheteur_id": ["a1"],
|
||||||
|
"acheteur_nom": ["ACHETEUR 1"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
result = add_links(dff)
|
||||||
|
nom_value = result["acheteur_nom"][0]
|
||||||
|
id_value = result["acheteur_id"][0]
|
||||||
|
|
||||||
|
# acheteur_nom should contain detail link + observatoire link
|
||||||
|
assert "/acheteurs/a1" in nom_value
|
||||||
|
assert "ACHETEUR 1" in nom_value
|
||||||
|
assert "/observatoire?acheteur_id=a1" in nom_value
|
||||||
|
assert "📊" in nom_value
|
||||||
|
|
||||||
|
# acheteur_id should NOT contain observatoire link
|
||||||
|
assert "/observatoire" not in id_value
|
||||||
|
|||||||
Reference in New Issue
Block a user