def test_notification_when_approval_fails(self, mock_send_notification): """ Ensure the notification function is triggered when refunds are initiated, and cannot be automatically approved. """ refund_id = 1 failed_refund_id = 2 with mock_create_refund(status=201, response=[refund_id, failed_refund_id]): with mock_process_refund(refund_id, reset_on_exit=False): with mock_process_refund(failed_refund_id, status=500, reset_on_exit=False): self.send_signal() self.assertTrue(mock_send_notification.called) mock_send_notification.assert_called_with(self.course_enrollment, [failed_refund_id])
def test_notification_when_approval_fails(self, mock_send_notification): """ Ensure the notification function is triggered when refunds are initiated, and cannot be automatically approved. """ refund_id = 1 failed_refund_id = 2 with mock_create_refund(status=201, response=[refund_id, failed_refund_id]): with mock_process_refund(refund_id, reset_on_exit=False): with mock_process_refund(failed_refund_id, status=500, reset_on_exit=False): self.send_signal() self.assertTrue(mock_send_notification.called) mock_send_notification.assert_called_with( self.course_enrollment, [failed_refund_id])
def test_no_notification_after_approval(self, mock_send_notification): """ Ensure the notification function is triggered when refunds are initiated, and cannot be automatically approved. """ refund_id = 1 with mock_create_refund(status=201, response=[refund_id]): with mock_process_refund(refund_id, reset_on_exit=False): self.send_signal() self.assertFalse(mock_send_notification.called) last_request = httpretty.last_request() self.assertDictEqual(json.loads(last_request.body), {'action': 'approve_payment_only'})