Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[208370] RDI - import error messages formatting #4180

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
},
],
),
Expand Down Expand Up @@ -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",
},
]

Expand Down
10 changes: 5 additions & 5 deletions backend/hct_mis_api/apps/registration_datahub/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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"):
Expand Down Expand Up @@ -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})
Expand Down
Loading