From 13d4af1979955e5e4393342cb5df5f074408441f Mon Sep 17 00:00:00 2001
From: Paulina Kujawa
Date: Fri, 30 Aug 2024 00:47:40 +0200
Subject: [PATCH 1/2] fix some validation msgs inconsistency
---
.../test_xlsx_upload_validators_methods.py | 56 +++++++++----------
.../apps/registration_datahub/validators.py | 10 ++--
2 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_xlsx_upload_validators_methods.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_xlsx_upload_validators_methods.py
index ec1be97383..bec2bf2b21 100644
--- a/backend/hct_mis_api/apps/registration_datahub/tests/test_xlsx_upload_validators_methods.py
+++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_xlsx_upload_validators_methods.py
@@ -188,7 +188,7 @@ def test_rows_validator_too_many_head_of_households(self) -> None:
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, There are multiple head of households for household with id: 3",
+ "message": "Sheet: 'Individuals', There are multiple head of households for household with id: 3",
}
]
self.assertEqual(expected, upload_xlsx_instance_validator.errors)
@@ -336,107 +336,107 @@ def test_rows_validator(self) -> None:
{
"row_number": 8,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, There is no household with provided id: TEXT",
+ "message": "Sheet: 'Individuals', There is no household with provided id: TEXT",
},
{
"row_number": 29,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, There is no household with provided id: 52",
+ "message": "Sheet: 'Individuals', There is no household with provided id: 52",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 34, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 34, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 35, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 35, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 36, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 36, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 37, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 37, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 38, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 38, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 39, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 39, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 40, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 40, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 41, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 41, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 42, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 42, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 43, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 43, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 44, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 44, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 45, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 45, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 46, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 46, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 47, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 47, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 48, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 48, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 49, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 49, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 50, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 50, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: 51, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 51, has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: Individuals, Household with id: Some Text, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: Some Text, has to have a head of household",
},
],
),
@@ -575,32 +575,32 @@ def test_validate_incorrect_admin_area(self) -> None:
{
"header": "admin1_h_c",
"row_number": 3,
- "message": "Sheet Households: Area with code: F-35 does not exist",
+ "message": "Sheet: 'Households': Area with code: F-35 does not exist",
},
{
"header": "admin2_h_c",
"row_number": 3,
- "message": "Sheet Households: Area with code: F-35 does not exist",
+ "message": "Sheet: 'Households': Area with code: F-35 does not exist",
},
{
"header": "admin1_h_c",
"row_number": 4,
- "message": "Sheet Households: Area with code: F-35 does not exist",
+ "message": "Sheet: 'Households': Area with code: F-35 does not exist",
},
{
"header": "admin2_h_c",
"row_number": 4,
- "message": "Sheet Households: Area with code: F-35 does not exist",
+ "message": "Sheet: 'Households': Area with code: F-35 does not exist",
},
{
"header": "admin1_h_c",
"row_number": 6,
- "message": "Sheet Households: Area with code: F-35 does not exist",
+ "message": "Sheet: 'Households': Area with code: F-35 does not exist",
},
{
"header": "admin2_h_c",
"row_number": 6,
- "message": "Sheet Households: Area with code: F-35 does not exist",
+ "message": "Sheet: 'Households': Area with code: F-35 does not exist",
},
]
diff --git a/backend/hct_mis_api/apps/registration_datahub/validators.py b/backend/hct_mis_api/apps/registration_datahub/validators.py
index 85e3d44366..fdcdf4fac9 100644
--- a/backend/hct_mis_api/apps/registration_datahub/validators.py
+++ b/backend/hct_mis_api/apps/registration_datahub/validators.py
@@ -781,7 +781,7 @@ def has_value(cell: Cell) -> bool:
delivery_mechanisms_data[row_number][header.value] = value
if current_household_id and current_household_id not in self.household_ids:
- message = f"Sheet: Individuals, There is no household with provided id: {current_household_id}"
+ message = f"Sheet: 'Individuals', There is no household with provided id: {current_household_id}"
invalid_rows.append({"row_number": row_number, "header": "relationship_i_c", "message": message})
for header_value_doc in self.DOCUMENTS_ISSUING_COUNTRIES_MAPPING.values():
@@ -795,11 +795,11 @@ def has_value(cell: Cell) -> bool:
for household_id, count in self.head_of_household_count.items():
if count == 0:
message = (
- f"Sheet: Individuals, Household with id: {household_id}, has to have a head of household"
+ f"Sheet: 'Individuals', Household with id: {household_id} has to have a head of household"
)
invalid_rows.append({"row_number": 0, "header": "relationship_i_c", "message": message})
elif count > 1:
- message = f"Sheet: Individuals, There are multiple head of households for household with id: {household_id}"
+ message = f"Sheet: 'Individuals', There are multiple head of households for household with id: {household_id}"
invalid_rows.append({"row_number": 0, "header": "relationship_i_c", "message": message})
if sheet.title in ("Households", "People"):
@@ -835,10 +835,10 @@ def validate_admin_areas(
row_number, header_name, p_code = code_tuple
area = queryset.filter(p_code=p_code).first()
if not area:
- message = f"Sheet Households: Area with code: {p_code} does not exist"
+ message = f"Sheet: 'Households': Area with code: {p_code} does not exist"
elif area.area_type.country not in business_area_countries:
message = (
- f"Sheet Households: Admin Area: {p_code} unavailable in Business Area: {business_area_slug}"
+ f"Sheet: 'Households': Admin Area: {p_code} unavailable in Business Area: {business_area_slug}"
)
if message:
invalid_rows.append({"row_number": row_number, "header": header_name, "message": message})
From 6f6d18a9c583d07e043290ac839c27b0c7210866 Mon Sep 17 00:00:00 2001
From: Paulina Kujawa
Date: Fri, 30 Aug 2024 14:25:15 +0200
Subject: [PATCH 2/2] fix tests more
---
.../test_xlsx_upload_validators_methods.py | 38 +++++++++----------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_xlsx_upload_validators_methods.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_xlsx_upload_validators_methods.py
index bec2bf2b21..d050d18f50 100644
--- a/backend/hct_mis_api/apps/registration_datahub/tests/test_xlsx_upload_validators_methods.py
+++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_xlsx_upload_validators_methods.py
@@ -346,97 +346,97 @@ def test_rows_validator(self) -> None:
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 34, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 34 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 35, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 35 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 36, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 36 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 37, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 37 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 38, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 38 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 39, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 39 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 40, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 40 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 41, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 41 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 42, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 42 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 43, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 43 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 44, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 44 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 45, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 45 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 46, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 46 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 47, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 47 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 48, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 48 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 49, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 49 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 50, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 50 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: 51, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: 51 has to have a head of household",
},
{
"row_number": 0,
"header": "relationship_i_c",
- "message": "Sheet: 'Individuals', Household with id: Some Text, has to have a head of household",
+ "message": "Sheet: 'Individuals', Household with id: Some Text has to have a head of household",
},
],
),