Skip to content

Commit

Permalink
improved assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mudiwa Matanda authored and Mudiwa Matanda committed Feb 5, 2024
1 parent 9656805 commit 4b886f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
7 changes: 3 additions & 4 deletions home/tests/contentpage_required_fields.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
message,slug,parent,web_title,locale
0,main-menu,,Main Menu,English
1,main-menu-first-time-user,Main Menu,main menu first time user,English
1,health-info,main menu first time user,health info,English
1,self-help,main menu first time user,self-help,English
0,main_menu,,Main Menu,English
1,first_time_user,Main Menu,main menu first time user,English
1,health_info,main menu first time user,health info,English
24 changes: 12 additions & 12 deletions home/tests/test_content_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,38 +849,38 @@ def test_cpi_validation_failure_update(self, csv_impexp: ImportExport) -> None:

def test_ContentPageIndex_required_fields(self, csv_impexp: ImportExport) -> None:
"""
Importing an CSV file with only the required fields shoud not break
Importing an CSV file with only the required fields for a ContentPageIndex shoud not break
"""

csv_bytes = csv_impexp.import_file("contentpage_index_required_fields.csv")
content = csv_impexp.export_content()
src, dst = csv_impexp.csvs2dicts(csv_bytes, content)

content_pages = ContentPageIndex.objects.all()

for page_data, content_page in zip(src, content_pages, strict=False):
assert page_data.get("slug", "") == content_page.slug
[main_menu] = ContentPageIndex.objects.all()
assert main_menu.slug == "main-menu"

assert content_pages.count() == len(list(src))
assert ContentPageIndex.objects.all().count() == len(list(src))

def test_ContentPage_required_fields(self, csv_impexp: ImportExport) -> None:
"""
Importing an CSV file with only the required fields shoud not break
Importing an CSV file with only the required fields for a ContentPage shoud not break
"""

csv_bytes = csv_impexp.import_file("contentpage_required_fields.csv")
content = csv_impexp.export_content()
src, dst = csv_impexp.csvs2dicts(csv_bytes, content)

[main_menu] = ContentPageIndex.objects.all()
[first_time_user, health_info] = ContentPage.objects.all()

assert main_menu.slug == "main_menu"
assert first_time_user.slug == "first_time_user"
assert health_info.slug == "health_info"

content_pages = list(ContentPageIndex.objects.all()) + list(
ContentPage.objects.all()
)

for page_data, content_page in zip(src, content_pages, strict=False):
assert page_data.get("slug", "") == content_page.slug

assert len(content_pages) == len(list(src))


Expand Down

0 comments on commit 4b886f2

Please sign in to comment.