Skip to content

Commit

Permalink
test passing with new field
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlamallama committed Feb 1, 2024
1 parent 752f387 commit 8c89258
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ class WhatsappBlock(blocks.StructBlock):
max_num=3,
)

footer = blocks.CharBlock(
help_text="Footer cannot exceed 60 characters.",
required=False,
validators=(MaxLengthValidator(60),),
)

class Meta:
icon = "user"
form_classname = "whatsapp-message-block struct-block"
Expand Down
1 change: 1 addition & 0 deletions home/tests/page_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class WABlk(ContentBlock):
variation_messages: list[VarMsg] = field(default_factory=list)
example_values: list[str] = field(default_factory=list)
buttons: list[Btn] = field(default_factory=list)
footer: str | None = None

def to_dict(self) -> dict[str, Any]:
varmsgs = [vm.to_dict() for vm in self.variation_messages]
Expand Down
1 change: 1 addition & 0 deletions home/tests/test_content_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def add_body_fields(page: DbDict) -> DbDict:
"next_prompt": "",
"example_values": [],
"variation_messages": [],
"footer": None,
},
)
if "sms_body" in page["fields"]:
Expand Down
2 changes: 2 additions & 0 deletions home/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def create_message_value(
example_values=None,
next_prompt="",
buttons=None,
footer="",
):
return {
"image": image,
Expand All @@ -344,6 +345,7 @@ def create_message_value(
"variation_messages": variation_messages,
"next_prompt": next_prompt,
"buttons": buttons or [],
"footer": footer,
}

def create_image(self, width=0, height=0):
Expand Down
4 changes: 4 additions & 0 deletions home/tests/test_page_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def test_build_simple_pages() -> None:
"buttons": [],
"example_values": [],
"variation_messages": [],
"footer": None,
},
),
]
Expand Down Expand Up @@ -260,6 +261,7 @@ def test_build_variations() -> None:
{"message": "Single male", "variation_restrictions": v_single_male},
{"message": "Comp male", "variation_restrictions": v_complicated_male},
],
"footer": None,
},
{
"message": "Message 2, variable placeholders as well {{0}}",
Expand All @@ -271,13 +273,15 @@ def test_build_variations() -> None:
"variation_messages": [
{"message": "Teen", "variation_restrictions": [("age", "15-18")]}
],
"footer": None,
},
{
"message": "Message 3 with no variation",
"next_prompt": "end",
"buttons": [("next_message", {"title": "end"})],
"example_values": [],
"variation_messages": [],
"footer": None,
},
]

Expand Down

0 comments on commit 8c89258

Please sign in to comment.