Skip to content

Commit

Permalink
Correction des transformations quand la colonne origin et destination…
Browse files Browse the repository at this point in the history
… est la même (#1126)
  • Loading branch information
kolok authored Dec 11, 2024
1 parent dbdb5e8 commit 22b832b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dags/sources/tasks/business_logic/source_data_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def source_data_normalize(
df[transformation["destination"]] = df[transformation["origin"]].apply(
TRANSFORMATION_MAPPING[function_name]
)
df.drop(columns=[transformation["origin"]], inplace=True)
if transformation["destination"] != transformation["origin"]:
df.drop(columns=[transformation["origin"]], inplace=True)

# DEBUT Traitement des identifiants

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class TestSourceDataNormalize:
- [ ] test Suppresion des colonnes non voulues
- [ ] test ignore_duplicates
- [ ] test produitsdechets_acceptes vide ou None
- [ ] test transformation from column_transformations is called
- [x] test transformation from column_transformations is called
"""

@pytest.fixture
Expand Down Expand Up @@ -523,7 +523,12 @@ def test_column_transformations_is_called(self, source_data_normalize_kwargs):
"origin": "nom origin",
"transformation": "test_fct",
"destination": "nom destination",
}
},
{
"origin": "nom",
"transformation": "test_fct",
"destination": "nom",
},
]
source_data_normalize_kwargs["df_acteur_from_source"] = pd.DataFrame(
{
Expand All @@ -532,7 +537,8 @@ def test_column_transformations_is_called(self, source_data_normalize_kwargs):
"source_id": ["source_id1"],
"acteur_type_id": ["decheterie"],
"produitsdechets_acceptes": ["Plastic Box"],
"nom origin": ["nom"],
"nom origin": ["nom origin 1"],
"nom": ["nom"],
}
)

Expand All @@ -541,6 +547,9 @@ def test_column_transformations_is_called(self, source_data_normalize_kwargs):
assert "nom destination" in df.columns
assert df["nom destination"].iloc[0] == "success"

assert "nom" in df.columns
assert df["nom"].iloc[0] == "success"


class TestDfNormalizePharmacie:
"""
Expand Down

0 comments on commit 22b832b

Please sign in to comment.