Skip to content

Commit

Permalink
added another test for no contentpage and no fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Mudiwa Matanda authored and Mudiwa Matanda committed Feb 25, 2025
1 parent 842113c commit bb73a07
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion home/import_ordered_content_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _add_pages(
f"Content page not found for slug '{page.page_slug}' in locale '{locale}'",
index,
)
if not page.page_slug and (
if (not page.page_slug or page.page_slug == "-") and (
page.time or page.unit or page.before_or_after or page.contact_field
):
raise ImportException(
Expand Down
2 changes: 2 additions & 0 deletions home/tests/import-export-data/simple_ordered_set.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Name,Profile Fields,Page Slugs,Time,Unit,Before Or After,Contact Field,Slug,Locale
Ordered,,,,,,,Slug,en
18 changes: 18 additions & 0 deletions home/tests/test_content_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,24 @@ def test_import_ordered_content_sets_duplicate_slug(
page = pages[0][1]
assert page["contentpage"].slug == "first_time_user"

def test_import_simple_ordered_sets_csv(self, csv_impexp: ImportExport) -> None:
"""
Importing a CSV file with ordered content sets without any contentpage should not break
"""

content = csv_impexp.read_bytes("simple_ordered_set.csv")
csv_impexp.import_ordered_sets(content)

en = Locale.objects.get(language_code="en")

ordered_set = OrderedContentSet.objects.filter(
slug="slug", locale=en
).first()

assert ordered_set.name == "Ordered"
pages = unwagtail(ordered_set.pages)
assert len(pages) == 0

def test_import_ordered_sets_csv(self, csv_impexp: ImportExport) -> None:
"""
Importing a CSV file with ordered content sets should not break
Expand Down

0 comments on commit bb73a07

Please sign in to comment.