-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,36 +334,32 @@ def test_email_freshdesk_ticket(self, mocker, notify_api: Flask, contact_form_em | |
class TestEmailFreshdeskSensitiveService: | ||
def test_email_freshdesk_ticket_sensitive_service_success(self, mocker, notify_api): | ||
"""Test successful sending of sensitive service email""" | ||
mock_email_ticket = mocker.patch.object(freshdesk.Freshdesk, 'email_freshdesk_ticket') | ||
|
||
with set_config_values(notify_api, { | ||
"SENSITIVE_SERVICE_EMAIL": "[email protected]", | ||
"CONTACT_FORM_SENSITIVE_SERVICE_EMAIL_TEMPLATE_ID": "template-123" | ||
}): | ||
mock_email_ticket = mocker.patch.object(freshdesk.Freshdesk, "email_freshdesk_ticket") | ||
|
||
with set_config_values( | ||
notify_api, | ||
{ | ||
"SENSITIVE_SERVICE_EMAIL": "[email protected]", | ||
"CONTACT_FORM_SENSITIVE_SERVICE_EMAIL_TEMPLATE_ID": "template-123", | ||
}, | ||
): | ||
with notify_api.app_context(): | ||
freshdesk_client = freshdesk.Freshdesk(ContactRequest(email_address="[email protected]")) | ||
freshdesk_client.email_freshdesk_ticket_sensitive_service() | ||
|
||
mock_email_ticket.assert_called_once_with( | ||
"[email protected]", | ||
"template-123" | ||
) | ||
mock_email_ticket.assert_called_once_with("[email protected]", "template-123") | ||
|
||
def test_email_freshdesk_ticket_sensitive_service_no_email(self, mocker, notify_api): | ||
"""Test handling when sensitive service email not configured""" | ||
mock_email_ticket = mocker.patch.object(freshdesk.Freshdesk, 'email_freshdesk_ticket') | ||
mock_logger = mocker.patch('app.clients.freshdesk.current_app.logger.error') | ||
mock_email_ticket = mocker.patch.object(freshdesk.Freshdesk, "email_freshdesk_ticket") | ||
mock_logger = mocker.patch("app.clients.freshdesk.current_app.logger.error") | ||
|
||
with set_config_values(notify_api, { | ||
"SENSITIVE_SERVICE_EMAIL": None, | ||
"CONTACT_FORM_SENSITIVE_SERVICE_EMAIL_TEMPLATE_ID": "template-123" | ||
}): | ||
with set_config_values( | ||
notify_api, {"SENSITIVE_SERVICE_EMAIL": None, "CONTACT_FORM_SENSITIVE_SERVICE_EMAIL_TEMPLATE_ID": "template-123"} | ||
): | ||
with notify_api.app_context(): | ||
freshdesk_client = freshdesk.Freshdesk(ContactRequest(email_address="[email protected]")) | ||
freshdesk_client.email_freshdesk_ticket_sensitive_service() | ||
|
||
mock_logger.assert_called_once_with("Sensitive service email address not set") | ||
mock_email_ticket.assert_called_once_with( | ||
None, | ||
"template-123" | ||
) | ||
mock_email_ticket.assert_called_once_with(None, "template-123") |