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

New form validation test fixes #311

Merged
merged 5 commits into from
Apr 10, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Increased SMS limit to 459 characters
- Validate character limit fir footer and list items when importing
- Add Document upload extension validation
- Update tests to use model validations and update test data

-->
## v1.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Menu 4,0,17,whatsapp-template-testing,,whatsapp template testing,,,,,,,,,,,,,,,,
Menu 5,0,164,import-export,,Import Export,,,,,,,,,,,,,,,,,497bdc1f-43fc-4925-80a1-e68cb942faa4,,,,English,,,,,,,,
Sub 5.1,1,165,cp-import-export,Import Export,CP-Import/export,,,WA import export data,Message 1 contains an image,,,,,,,,,,,,,8ac50daf-de21-4d05-b697-6d983b7ed3d5,"Tag2, Tag1",Quick reply1,"Trigger2, Trigger1",English,,[],/admin/images/usage/4/,,,ma_qa_temp,,
,1,165,cp-import-export,,,,,,,,gender: male,Variation message one for Gender Male,,,,,,,,,,,,,,,,,,,,,,
,2,165,cp-import-export,,,,,,"Message2 has a document attached, lets add some variable placeholders as well {{0}}",,,,,,,,,,,,,,,,,,,[],,/admin/documents/usage/1/,,,,
,2,165,cp-import-export,,,,,,"Message2 has a document attached",,,,,,,,,,,,,,,,,,,[],,/admin/documents/usage/1/,,,,
,2,165,cp-import-export,,,,,,,,gender: empty,Variation message one for Gender Rather not say,,,,,,,,,,,,,,,,,,,,,,
,3,165,cp-import-export,,,,,,Message 3 with no variation but has an audio clip,,,,,,,,,,,,,,,,,,,[],,,/admin/media/usage/1/,,,
Sub 5.2,1,166,ma_qa_temp,Import Export,MA QA Temp,,,,,,,,,,,,,,,,,e9793b5f-f8c7-46c5-8a5e-bd9b8f00fee9,,,,English,,,,,,,,
Sub 5.2,1,166,ma_qa_temp,Import Export,MA QA Temp,,,,,,,,,,,,,,,,,e9793b5f-f8c7-46c5-8a5e-bd9b8f00fee9,,,,English,,,,,,,,
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure,message,page_id,slug,parent,web_title,web_subtitle,web_body,whatsapp_title,whatsapp_body,whatsapp_template_name,whatsapp_template_category,example_values,variation_title,variation_body,sms_title,sms_body,ussd_title,ussd_body,messenger_title,messenger_body,viber_title,viber_body,translation_tag,tags,quick_replies,triggers,locale,next_prompt,buttons,image_link,doc_link,media_link,related_pages
Menu 1,0,1303,appointment-reminders,,Appointment reminders,,,,,,,,,,,,,,,,,,8cff04aa-cf08-4120-88b4-e2269b7d5d80,,,,English,,,,,,
Sub 1.13,1,1467,mnch_appointment_child_2,Appointment reminders,Appointment child 2,,,mnch_appointment_child_2,"Hi {{1}}
{{2}} {{3}}",mnch_appointment_child_2,MARKETING,Helen,,,,,,,,,,,0c9857a5-e381-49d7-b2fd-123348c4a373,,,,English,,,,,,
{{2}} {{3}}",mnch_appointment_child_2,MARKETING,"Helen,Good, Great",,,,,,,,,,,0c9857a5-e381-49d7-b2fd-123348c4a373,,,,English,,,,,,
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can return to this main menu at any time by replying 🏠
Choose what you'd like to know more about by tapping a button below ⬇️",,,5892bccd-8025-419d-9a8e-a6a37b755dbf,menu,"Self-help🌬️, Settings⚙️, Health Info🏥",Main menu🏠,English,,[],,,,,[],
Sub 1.1.1,1,,health-info,main menu first time user,health info,,,health info,"*Health information* 🏥

Get information and advice from WHO by tapping on a button below ⬇️",,,This is a long list item that exceed character limit.,Health Info SMS Title,*Health Info SMS Body*,Health Info USSD Title,*Health Info USSD Body*,health info,"*Health information* 🏥
Get information and advice from WHO by tapping on a button below ⬇️",,,,Health Info SMS Title,*Health Info SMS Body*,Health Info USSD Title,*Health Info USSD Body*,health info,"*Health information* 🏥

Get information and advice from WHO by tapping on a button below ⬇️",,,c9d6309e-173f-4c1d-bbaf-440b1fd4415f,health_info,,,English,,[],,,,,[],This is a test footer with a very long footer. This footer has reach maximum characters allowed in the footer.
Sub 1.1.2,1,,self-help,main menu first time user,self-help,,,self-help,"*Self-help programs* 🌬️
Expand Down
19 changes: 11 additions & 8 deletions home/tests/test_content_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,13 +1002,17 @@ def test_ContentPage_required_fields(self, csv_impexp: ImportExport) -> None:

def test_footer_maximum_characters(self, csv_impexp: ImportExport) -> None:
"""
Importing an CSV file with list_items and and footer characters exceeding maximum charactercount
Importing an CSV file with footer and and footer characters exceeding maximum charactercount
"""
with pytest.raises(ImportException) as e:
csv_impexp.import_file("whatsapp_footer_max_characters.csv")

assert isinstance(e.value, ImportException)
assert e.value.row_num == 4
assert (
e.value.message
== "footer too long: This is a test footer with a very long footer. This footer has reach maximum characters allowed in the footer."
)

def test_list_items_maximum_characters(self, csv_impexp: ImportExport) -> None:
"""
Expand Down Expand Up @@ -1424,20 +1428,18 @@ def test_variations(self, impexp: ImportExport) -> None:
home_page = HomePage.objects.first()
imp_exp = PageBuilder.build_cpi(home_page, "import-export", "Import Export")

m1vars = [
VarMsg("Single male", gender="male", relationship="single"),
VarMsg("Complicated male", gender="male", relationship="complicated"),
]

cp_imp_exp_wablks = [
WABlk(
"Message 1",
next_prompt="Next message",
buttons=[NextBtn("Next message")],
variation_messages=m1vars,
variation_messages=[
VarMsg("Var'n for Single", relationship="single"),
VarMsg("Var'n for Complicated", relationship="complicated"),
],
),
WABlk(
"Message 2, variable placeholders as well {{0}}",
"Message 2",
buttons=[PageBtn("Import Export", page=imp_exp)],
variation_messages=[VarMsg("Var'n for Rather not say", gender="empty")],
),
Expand All @@ -1449,6 +1451,7 @@ def test_variations(self, impexp: ImportExport) -> None:
title="CP-Import/export",
bodies=[WABody("WA import export data", cp_imp_exp_wablks)],
)

# Save and publish cp_imp_exp again so the revision numbers match up after import.
rev = cp_imp_exp.save_revision()
rev.publish()
Expand Down
Loading