Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
smcmurtry committed Jan 14, 2025
1 parent 238af1f commit 22f08d3
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions tests/app/clients/test_freshdesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 22f08d3

Please sign in to comment.