@mock.patch('transcoder.tasks.transcode', mock.Mock())
@mock.patch('post_office.mailgun.requests', mock.Mock())
@mock.patch('utils.telegram.requests.post')
def test_when_capture_payment_fails_it_should_send_alert_message_to_staff(self, mock1, telegram_request_post):
    expected_call = mock.call(url=f'{TELEGRAM_BOT_API_URL}/sendMessage', data=json.dumps({'chat_id': os.environ['TELEGRAM_GROUP_ID'], 'text': 'OCORREU UM ERRO AO CAPTURAR UM PAGAMENTO. Verifique o Sentry: https://sentry.io/organizations/viggio-sandbox/issues/?project=1770932'}), headers={'Content-Type': 'application/json'})
    method_path = 'request_shoutout.adapters.db.orm.WirecardPaymentApi.capture_payment'
    with mock.patch(method_path, side_effect=Exception):
        response = self.client.post(reverse('request_shoutout:fulfill'), self.request_data, format='multipart')
    self.assertEqual(response.status_code, status.HTTP_201_CREATED)
    self.assertEqual(telegram_request_post.mock_calls, [expected_call])
@mock.patch('transcoder.tasks.transcode', mock.Mock())
@mock.patch('post_office.mailgun.requests', mock.Mock())
@mock.patch('utils.telegram.requests.post')
def test_when_capture_payment_fails_it_should_send_alert_message_to_staff(self, mock1, telegram_request_post):
    expected_call = mock.call(url=f'{TELEGRAM_BOT_API_URL}/sendMessage', data=json.dumps({'chat_id': os.environ['TELEGRAM_GROUP_ID'], 'text': 'OCORREU UM ERRO AO CAPTURAR UM PAGAMENTO. Verifique o Sentry: https://sentry.io/organizations/viggio-sandbox/issues/?project=1770932'}), headers={'Content-Type': 'application/json'})
    method_path = 'request_shoutout.adapters.db.orm.WirecardPaymentApi.capture_payment'
    with mock.patch(method_path, side_effect=Exception):
        response = self.client.post(reverse('request_shoutout:fulfill'), self.request_data, format='multipart')
    self.assertEqual(response.status_code, status.HTTP_201_CREATED)
    self.assertEqual(telegram_request_post.mock_calls, [expected_call])