Skip to content

Commit

Permalink
[#2530] One additional test for base action cancel - multiple emails
Browse files Browse the repository at this point in the history
  • Loading branch information
pbanaszkiewicz committed Oct 19, 2023
1 parent bda7117 commit f1e2a02
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions amy/emails/tests/actions/test_base_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,39 @@ def test_call(
request, instance.signal, mock_cancel_email.return_value
)

@patch("emails.actions.base_action.feature_flag_enabled", return_value=True)
@patch("emails.actions.base_action.person_from_request")
@patch("emails.actions.base_action.EmailController.cancel_email")
@patch("emails.actions.base_action.messages_action_cancelled")
def test_call__multiple_scheduled_emails(
self,
mock_action_cancelled: MagicMock,
mock_cancel_email: MagicMock,
mock_person_from_request: MagicMock,
mock_feature_flag_enabled: MagicMock,
) -> None:
# Arrange
instance = BaseActionCancelForTesting()
event = instance.get_generic_relation_object({})

template = self.setUpEmailTemplate(instance.signal)
self.setUpScheduledEmail(template, event)
self.setUpScheduledEmail(template, event)

# Act
sender = MagicMock()
request = RequestFactory().get("/")
kwargs = {"request": request}
instance(sender, **kwargs)

# Assert
mock_feature_flag_enabled.assert_called_once_with(
"EMAIL_MODULE", f"{instance.signal}_remove", **kwargs
)
self.assertEqual(mock_person_from_request.call_count, 2)
self.assertEqual(mock_cancel_email.call_count, 2)
self.assertEqual(mock_action_cancelled.call_count, 2)

@patch("emails.actions.base_action.feature_flag_enabled", return_value=False)
@patch("emails.actions.base_action.EmailController.cancel_email")
def test_call__feature_flag_not_enabled(
Expand Down

0 comments on commit f1e2a02

Please sign in to comment.