Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlamallama committed Feb 17, 2025
1 parent c1a25a2 commit 0697c48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions home/import_content_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ def _create_interactive_items(self, row_field, page, slug, locale, field_name) -
"value": {"title": field["title"], "form": form.id},
}
)

elif not field["type"]:
pass
else:
raise ImportException(
f"{field_name} with invalid type '{field['type']}'"
Expand All @@ -423,7 +424,7 @@ def add_message_to_shadow_content_page_from_row(

page = self._get_shadow_page(row.slug, locale)
buttons = self._create_interactive_items(row.buttons, page, row.slug, locale, "button")
list_items = self._create_interactive_items(row.list_items, page, row.slug, locale, "List Item")
list_items = self._create_interactive_items(row.list_items, page, row.slug, locale, "list item")

page.whatsapp_body.append(
ShadowWhatsappBlock(
Expand Down
4 changes: 2 additions & 2 deletions home/tests/test_content_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ def test_list_item_descriptive_error_message(
with pytest.raises(ImportException) as e:
csv_impexp.import_file("list_items_with_errors.csv")
assert e.value.row_num == 3
assert e.value.message == ["List item is missing key 'type'"]
assert e.value.message == ["list item is missing key 'type'"]

def test_list_item_type_error_message(self, csv_impexp: ImportExport) -> None:
"""
Expand All @@ -1692,7 +1692,7 @@ def test_list_item_type_error_message(self, csv_impexp: ImportExport) -> None:
with pytest.raises(ImportException) as e:
csv_impexp.import_file("list_items_with_type_error.csv")
assert e.value.row_num == 3
assert e.value.message == ["List item with invalid type 'new_type'"]
assert e.value.message == ["list item with invalid type 'new_type'"]


@pytest.mark.django_db
Expand Down

0 comments on commit 0697c48

Please sign in to comment.