Skip to content

Commit

Permalink
added WA title check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mudiwa Matanda authored and Mudiwa Matanda committed Jan 23, 2024
1 parent 435b92f commit 7f271aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def clean(self):
0: StreamBlockValidationError(
{
"message": ValidationError(
f'Variables must be sequential, starting with "{{1}}". Your first variable was "{actual_digit_variables[0]}"'
f'Variables must be sequential, starting with "{{1}}". Your first variable was "{actual_digit_variables}"'
)
}
)
Expand Down
49 changes: 23 additions & 26 deletions home/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,6 @@


class ContentPageTests(TestCase):
def create_message_value(
self,
image=None,
document=None,
media=None,
message="",
variation_messages=None,
example_values=None,
next_prompt="",
buttons=None,
is_whatsapp_template=False,
):
return {
"image": image,
"document": document,
"media": media,
"message": message,
"example_values": example_values,
"variation_messages": variation_messages,
"next_prompt": next_prompt,
"buttons": buttons or [],
"is_whatsapp_template": is_whatsapp_template,
}

def test_page_and_revision_rating(self):
page = create_page()

Expand Down Expand Up @@ -250,12 +226,33 @@ def test_template_not_submitted_with_no_message(
"""
home_page = HomePage.objects.first()
main_menu = PageBuilder.build_cpi(home_page, "main-menu", "Main Menu")

PageBuilder.build_cp(
parent=main_menu,
slug="ha-menu",
title="HealthAlert menu",
bodies=[WABody("WA Title", [])],
whatsapp_template_name="WA_Title_1",
)

mock_create_whatsapp_template.assert_not_called()

@override_settings(WHATSAPP_CREATE_TEMPLATES=True)
@mock.patch("home.models.create_whatsapp_template")
def test_template_submitted_with_no_title(self, mock_create_whatsapp_template):
"""
If the page is a WA template and how no title, then it shouldn't be submitted
"""

with self.assertRaises(ValidationError):
home_page = HomePage.objects.first()
main_menu = PageBuilder.build_cpi(home_page, "main-menu", "Main Menu")

PageBuilder.build_cp(
parent=main_menu,
slug="ha-menu",
slug="template-no-title",
title="HealthAlert menu",
bodies=[],
bodies=[WABody("", [])],
whatsapp_template_name="WA_Title_1",
)

Expand Down

0 comments on commit 7f271aa

Please sign in to comment.