Skip to content

Commit

Permalink
Format tcket description and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingphilippe committed Dec 18, 2024
1 parent 2c4baf4 commit 27409c9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
20 changes: 16 additions & 4 deletions app/clients/freshdesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,29 @@ def _generate_description(self):
# the ">" character breaks rendering for the freshdesk preview in slack
if self.contact.department_org_name:
self.contact.department_org_name = self.contact.department_org_name.replace(">", "/")
# Add custom limit only if requested
daily_email_volume = f"{self.contact.daily_email_volume}"
daily_sms_volume = f"{self.contact.daily_sms_volume}"
if self.contact.how_many_more_sms:
daily_email_volume += f" ({self.contact.how_many_more_email})"
if self.contact.how_many_more_sms:
daily_sms_volume += f" ({self.contact.how_many_more_sms})"

message = "<br>".join(
[
f"{self.contact.service_name} just requested to go live.",
"",
f"- Department/org: {self.contact.department_org_name}",
f"- Intended recipients: {self.contact.intended_recipients}",
f"- Purpose: {self.contact.main_use_case}",
f"- Notification types: {self.contact.notification_types}",
f"- Expected monthly volume: {self.contact.expected_volume}",
f"- Expected email volumes: Daily {self.contact.daily_email_volume} {f'({self.contact.how_many_more_email})' if self.contact.how_many_more_email else ''} / Yearly {self.contact.annual_email_volume}",
f"- Expected SMS volumes: Daily {self.contact.daily_sms_volume} {f'({self.contact.how_many_more_sms})' if self.contact.how_many_more_sms else ''} / Yearly {self.contact.annual_sms_volume}",
"",
"- Expected email volumes:",
f"- Daily: {daily_email_volume}",
f"- Yearly: {self.contact.annual_email_volume}",
"",
"- Expected SMS volumes:",
f"- Daily: {daily_sms_volume}",
f"- Yearly: {self.contact.annual_sms_volume}",
"---",
self.contact.service_url,
]
Expand Down
27 changes: 16 additions & 11 deletions tests/app/clients/test_freshdesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,19 @@ def match_json(request):
expected = {
"product_id": 42,
"subject": "Support Request",
"description": "t6 just requested to go live.<br><br>"
"description": "t6 just requested to go live.<br>"
"<br>"
"- Department/org: department_org_name<br>"
"- Intended recipients: internal, external, public<br>"
"- Purpose: main_use_case<br>"
"- Notification types: email, sms<br>"
"- Expected monthly volume: 100k+<br>"
"- Expected email volumes: Daily more_email (100001) / Yearly within_limit"
"- Expected SMS volumes: Daily 0 / Yearly 0"
"<br>"
"- Expected email volumes:<br>"
"- Daily: above_limit (None)<br>"
"- Yearly: within_limit<br>"
"<br>"
"- Expected SMS volumes:<br>"
"- Daily: more_sms (54321)<br>"
"- Yearly: above_limit<br>"
"---<br>"
"http://localhost:6012/services/8624bd36-b70b-4d4b-a459-13e1f4770b92",
"email": "[email protected]",
Expand Down Expand Up @@ -116,12 +121,12 @@ def match_json(request):
"service_url": "http://localhost:6012/services/8624bd36-b70b-4d4b-a459-13e1f4770b92",
"notification_types": "email, sms",
"expected_volume": "100k+",
"daily_email_volume": "more_email",
"annual_email_volume": "within-limit",
"daily_sms_volume": "0",
"annual_sms_volume": "0",
"how_many_more_email": 100001,
"how_many_more_sms": None,
"daily_email_volume": "above_limit",
"annual_email_volume": "within_limit",
"daily_sms_volume": "more_sms",
"annual_sms_volume": "above_limit",
"how_many_more_email": None,
"how_many_more_sms": 54321,
}
with notify_api.app_context():
response = freshdesk.Freshdesk(ContactRequest(**data)).send_ticket()
Expand Down

0 comments on commit 27409c9

Please sign in to comment.