Skip to content

Commit

Permalink
Mise à jour de la colonne Statut (#1078)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolok authored Nov 27, 2024
1 parent 561a1ea commit 237895d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dags/sources/tasks/business_logic/serialize_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def db_data_prepare(
)

df_joined.loc[
df_joined["proposition_services"].apply(lambda x: x == []), "status"
] = "SUPPRIME"
df_joined["proposition_services"].apply(lambda x: x == []), "statut"
] = "INACTIF"

df_joined.drop("acteur_id", axis=1, inplace=True)

Expand Down
13 changes: 12 additions & 1 deletion dags/sources/tasks/business_logic/source_data_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,18 @@ def source_data_normalize(
df[["adresse", "code_postal", "ville"]] = df.apply(extract_details, axis=1)

if "statut" in df.columns:
df["statut"] = df["statut"].map({1: "ACTIF", 0: "SUPPRIME"})
df["statut"] = df["statut"].map(
{
1: "ACTIF",
0: "SUPPRIME",
"ACTIF": "ACTIF",
"INACTIF": "INACTIF",
"SUPPRIME": "SUPPRIME",
}
)
df["statut"] = df["statut"].fillna("ACTIF")
else:
df["statut"] = "ACTIF"

if "public_accueilli" in df.columns:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class TestSourceDataNormalize:
- [ ] test merge_duplicated_acteurs
- [ ] test columns_to_add_by_default
- [ ] test adresse_format_ban
- [ ] test statut
- [x] test statut
- [x] test public_accueilli (+ suppression des pro)
- [x] test uniquement_sur_rdv
- [x] test exclusivite_de_reprisereparation
Expand Down Expand Up @@ -281,6 +281,48 @@ def source_data_normalize_kwargs(self, acteurtype_id_by_code, source_id_by_code)
"source_id_by_code": source_id_by_code,
}

@pytest.mark.parametrize(
"statut, statut_expected",
[
(None, "ACTIF"),
("fake", "ACTIF"),
(np.nan, "ACTIF"),
(0, "SUPPRIME"),
(1, "ACTIF"),
("ACTIF", "ACTIF"),
("INACTIF", "INACTIF"),
("SUPPRIME", "SUPPRIME"),
],
)
def test_statut(self, statut, statut_expected, source_data_normalize_kwargs):
source_data_normalize_kwargs["df_acteur_from_source"] = pd.DataFrame(
{
"identifiant_externe": ["1"],
"ecoorganisme": ["source1"],
"source_id": ["source_id1"],
"acteur_type_id": ["decheterie"],
"produitsdechets_acceptes": ["Plastic Box"],
"statut": [statut],
}
)
df = source_data_normalize(**source_data_normalize_kwargs)

assert df["statut"].iloc[0] == statut_expected

def test_statut_no_column(self, source_data_normalize_kwargs):
source_data_normalize_kwargs["df_acteur_from_source"] = pd.DataFrame(
{
"identifiant_externe": ["1"],
"ecoorganisme": ["source1"],
"source_id": ["source_id1"],
"acteur_type_id": ["decheterie"],
"produitsdechets_acceptes": ["Plastic Box"],
}
)
df = source_data_normalize(**source_data_normalize_kwargs)

assert df["statut"].iloc[0] == "ACTIF"

@pytest.mark.parametrize(
"label_et_bonus, label_et_bonus_expected",
[
Expand Down

0 comments on commit 237895d

Please sign in to comment.