Skip to content

Commit

Permalink
style : make outputs a bit more clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
Osneil Drakes authored and Osneil Drakes committed Sep 11, 2024
1 parent bd4efcf commit 4f36273
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions gcf_data_mapper/parsers/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,18 @@ def map_family_data(
"""

family_metadata = map_family_metadata(row)
projects_id = row.at[FamilyColumnsNames.PROJECTS_ID.value]

# When processing the family metadata if there are any empty/falsy values we return None
# and skip the row. Therefore we don't want to process the rest of the family data so we
# return None in this conditional.
if family_metadata is None:
click.echo("🛑 Skipping row as family metadata has missing information")
click.echo(
f"🛑 Skipping row as family metadata has missing information, ProjectsID : {projects_id}"
)
return None

approved_ref = row.at[FamilyColumnsNames.APPROVED_REF.value]
projects_id = row.at[FamilyColumnsNames.PROJECTS_ID.value]
summary = row.at[FamilyColumnsNames.SUMMARY.value]
title = row.at[FamilyColumnsNames.TITLE.value]

Expand Down
5 changes: 3 additions & 2 deletions tests/unit_tests/parsers/family/test_map_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,16 @@ def test_skips_processing_row_if_row_contains_empty_values(


def test_skips_processing_row_if_family_metadata_has_missing_data(
mock_family_row_no_result_areas, capsys
mock_family_row_no_result_areas: pd.Series, capsys
):
projects_id = mock_family_row_no_result_areas.ProjectsID
family_data = map_family_data(mock_family_row_no_result_areas)
assert family_data is None
captured = capsys.readouterr()
# We have two outputs, one from map_family_metadata pointing to the missing data and the second
# from map_family_data informing that the row is being skipped
map_family_data_output = captured.out.strip().split("\n")
assert (
"🛑 Skipping row as family metadata has missing information"
f"🛑 Skipping row as family metadata has missing information, ProjectsID : {projects_id}"
== map_family_data_output[1]
)

0 comments on commit 4f36273

Please sign in to comment.