Skip to content

Commit

Permalink
Feature/pdct 1454 fix status should be a list not a string (#18)
Browse files Browse the repository at this point in the history
* fix: update metadata types

- when validating we expect these fields to be a list

* fix: update document variant names

 - this matches the fields that we expect in the database

* fix: update family import id

- should contain 'family' not events

* test: update tests

---------

Co-authored-by: Osneil Drakes <[email protected]>
  • Loading branch information
odrakes-cpr and Osneil Drakes authored Sep 11, 2024
1 parent aa37326 commit 81f6f3f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions gcf_data_mapper/enums/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ class IgnoreDocumentTypes(Enum):


class DocumentVariantNames(Enum):
ORIGINAL = "Original Translation"
TRANSLATION = "Translated"
ORIGINAL = "Original Language"
TRANSLATION = "Translation"
2 changes: 1 addition & 1 deletion gcf_data_mapper/parsers/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def map_document_metadata(
return {
"import_id": f"GCF.document.{approved_ref}_{projects_id}.{doc_id}",
"family_import_id": f"GCF.family.{approved_ref}.{projects_id}",
"metadata": {"type": doc_type},
"metadata": {"type": [doc_type]},
"title": title,
"source_url": source_url.strip(),
"variant_name": variant_name,
Expand Down
2 changes: 1 addition & 1 deletion gcf_data_mapper/parsers/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def append_event(
gcf_events.append(
{
"import_id": f"GCF.event.{approved_ref}_{projects_id}.n{n_value:04}",
"family_import_id": f"GCF.event.{approved_ref}.{projects_id}",
"family_import_id": f"GCF.family.{approved_ref}.{projects_id}",
"event_title": event.type,
"date": row[event.column_name],
"event_type_value": event.type,
Expand Down
4 changes: 2 additions & 2 deletions gcf_data_mapper/parsers/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def map_family_metadata(row: pd.Series) -> Optional[dict]:
"result_areas": list(set(areas)),
"result_types": list(set(types)),
"sector": [row.at[FamilyColumnsNames.SECTOR.value]],
"status": status,
"status": [status],
"theme": [row.at[FamilyColumnsNames.THEME.value]],
}

Expand Down Expand Up @@ -192,7 +192,7 @@ def map_family_data(
# For now we are hard coding the category as MCF
"category": "MCF",
"collections": [],
"description": summary,
"summary": summary,
"geographies": geographies,
"import_id": import_id,
"metadata": family_metadata,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/parsers/family/test_map_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def parsed_family_data():
{
"category": "MCF",
"collections": [],
"description": "The Summary of the Project",
"summary": "The Summary of the Project",
"geographies": ["BGD"],
"import_id": "GCF.family.FP003.12660",
"metadata": {
Expand All @@ -24,7 +24,7 @@ def parsed_family_data():
"result_areas": ["Coastal protection and restoration"],
"result_types": ["Adaptation"],
"sector": ["Environment"],
"status": "Under Implementation",
"status": ["Under Implementation"],
"theme": ["Adaptation"],
},
"title": "Enhancing resilience of coastal ecosystems and communities",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def parsed_family_metadata():
"result_areas": ["The Area for the Result Area"],
"result_types": ["The Type for the Result Area"],
"sector": ["Private"],
"status": "Under Implementation",
"status": ["Under Implementation"],
"theme": ["Adaptation"],
}

Expand Down

0 comments on commit 81f6f3f

Please sign in to comment.